Запись из excel в acces скриптом vba
Формулировка задачи:
Добрый день. Возникает ошибка синтаксиса в инструкции INTO для следующего кода.
Помогите понять причину.
Sub makros() Dim cnn As ADODB.Connection, sql_qry As String, filetoopen As String filetoopen = "C:\Users\aem00511\Documents\ALLWells.accdb" Set cnn = New ADODB.Connection cnn.Open ConnectionString:="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filetoopen + ";" Dim str1 As String Dim str2 As String Dim str3 As String Dim str4 As Long Dim str5 As Date Dim str6 As Date Dim str7 As Double Dim str8 As Double Dim str9 As Double Dim str10 As Double Dim str11 As Double Dim str12 As Double Dim str13 As Double Dim str14 As Double Dim str15 As Double Dim str16 As Double Dim str17 As Double Dim str18 As Double Dim str19 As Double Dim str20 As Double Dim str21 As Double Dim str22 As Double Dim str23 As Double Dim str24 As Double Dim str25 As Double Dim str26 As Double Dim str27 As Double Dim str28 As Double Dim str29 As Double Dim str30 As Double Dim str31 As Double Dim str32 As Double Dim str33 As Double Dim str34 As Double Dim str35 As Double Dim str36 As Double Dim str37 As Double Dim str38 As Double Dim str39 As Double Dim str40 As Double Dim str42 As Double Dim str43 As Double Dim str44 As Double Dim str45 As Double Dim str46 As Double Dim str47 As Double Dim str48 As Double Dim str49 As String Dim I As Long I = 1 Dim sql_qry1 As String Dim sql_qry2 As String Dim sql_qry3 As String Dim sql_qry4 As String Dim sql_qry5 As String Dim sql_qry6 As String Dim sql_qry7 As String Dim sql_qry8 As String Dim sql_qry9 As String For I = 4 To 1364 str1 = Worksheets("Ñàìáóðã").Cells(I, 1).Value str2 = Worksheets("Ñàìáóðã").Cells(I, 2).Value str3 = Worksheets("Ñàìáóðã").Cells(I, 3).Value str4 = Worksheets("Ñàìáóðã").Cells(I, 4).Value str5 = Worksheets("Ñàìáóðã").Cells(I, 5).Value str6 = Worksheets("Ñàìáóðã").Cells(I, 6).Value str7 = Worksheets("Ñàìáóðã").Cells(I, 7).Value str8 = Worksheets("Ñàìáóðã").Cells(I, 8).Value str9 = Worksheets("Ñàìáóðã").Cells(I, 9).Value str10 = Worksheets("Ñàìáóðã").Cells(I, 10).Value str11 = Worksheets("Ñàìáóðã").Cells(I, 11).Value str12 = Worksheets("Ñàìáóðã").Cells(I, 12).Value str13 = Worksheets("Ñàìáóðã").Cells(I, 13).Value str14 = Worksheets("Ñàìáóðã").Cells(I, 14).Value str15 = Worksheets("Ñàìáóðã").Cells(I, 15).Value str16 = Worksheets("Ñàìáóðã").Cells(I, 16).Value str17 = Worksheets("Ñàìáóðã").Cells(I, 17).Value str18 = Worksheets("Ñàìáóðã").Cells(I, 18).Value str19 = Worksheets("Ñàìáóðã").Cells(I, 19).Value str20 = Worksheets("Ñàìáóðã").Cells(I, 20).Value str21 = Worksheets("Ñàìáóðã").Cells(I, 21).Value str22 = Worksheets("Ñàìáóðã").Cells(I, 22).Value str23 = Worksheets("Ñàìáóðã").Cells(I, 23).Value str24 = Worksheets("Ñàìáóðã").Cells(I, 24).Value str25 = Worksheets("Ñàìáóðã").Cells(I, 25).Value str26 = Worksheets("Ñàìáóðã").Cells(I, 26).Value str27 = Worksheets("Ñàìáóðã").Cells(I, 27).Value str28 = Worksheets("Ñàìáóðã").Cells(I, 28).Value str29 = Worksheets("Ñàìáóðã").Cells(I, 29).Value str30 = Worksheets("Ñàìáóðã").Cells(I, 30).Value str31 = Worksheets("Ñàìáóðã").Cells(I, 31).Value str32 = Worksheets("Ñàìáóðã").Cells(I, 32).Value str33 = Worksheets("Ñàìáóðã").Cells(I, 33).Value str34 = Worksheets("Ñàìáóðã").Cells(I, 34).Value str35 = Worksheets("Ñàìáóðã").Cells(I, 35).Value str36 = Worksheets("Ñàìáóðã").Cells(I, 36).Value str37 = Worksheets("Ñàìáóðã").Cells(I, 37).Value str38 = Worksheets("Ñàìáóðã").Cells(I, 38).Value str39 = Worksheets("Ñàìáóðã").Cells(I, 39).Value str40 = Worksheets("Ñàìáóðã").Cells(I, 40).Value str41 = Worksheets("Ñàìáóðã").Cells(I, 41).Value str42 = Worksheets("Ñàìáóðã").Cells(I, 42).Value str43 = Worksheets("Ñàìáóðã").Cells(I, 43).Value str44 = Worksheets("Ñàìáóðã").Cells(I, 44).Value str45 = Worksheets("Ñàìáóðã").Cells(I, 45).Value str46 = Worksheets("Ñàìáóðã").Cells(I, 46).Value str47 = Worksheets("Ñàìáóðã").Cells(I, 47).Value str48 = Worksheets("Ñàìáóðã").Cells(I, 48).Value str49 = Worksheets("Ñàìáóðã").Cells(I, 49).Value Dim strok As String sql_qry = "insert into tblWELL_TEST_GASCONDENSAT (UWI,Unique_Test_ID,Unique_Mode_ID,nomer_objecta,Data_start_ispit,Data_finish_ispit,Diametr_shtucera," sql_qry1 = "Diametr_diafragmi , Time_working, P_trubnoe, P_zatrubnoe, P_zaboinoe, P_separatora, P_izmeritelia, Depressia, Temperatura_na_ustie,Temperatura_separatora, Temperatura_na_izmeritele, " sql_qry2 = "Temperatura_zaboinaia,Postoiannaia_diafragmi,Davlenie_privedennoe,Temperatura_privedennaia,Koefficient_sverhszhimaemosti,Koefficient_sverhszhimaemosti_zaboinii,Plotnost_smesi,Parametr_sqrt(Tzp)," sql_qry3 = "Debit_gaza,Debit_zhidkosti,Debit_nefti,Debit_vodi,Procent_vodi,Procent_nefti,Debit_condensata_sirogo,Debit_condensata_stabilnogo,Debit_gaza_separacii,Gazovii_factor," sql_qry4 = "Vihod_condensata_sirogo,Vihod_condensata_stabilnogo,Koefficient_usadki,Plotnost_fluida,Skorost_potoka,DP2,DP,c,DP2-c,DP2-c/Q,DP/Q,Note) " sql_qry5 = "values ('" & str1 & "','" & str2 & "','" & str3 & "'," & str4 & ",'" & str5 & "','" & str6 & "'," & str7 & "," & str8 & "," & str9 & "," & str10 sql_qry6 = "," & str11 & "," & str12 & "," & str13 & "," & str14 & "," & str15 & "," & str16 & "," & str17 & "," & str18 & "," & str19 & "," & str20 sql_qry7 = "," & str21 & "," & str22 & "," & str23 & "," & str24 & "," & str25 & "," & str26 & "," & str27 & "," & str28 & "," & str29 & "," & str30 sql_qry8 = "," & str31 & "," & str32 & "," & str33 & "," & str34 & "," & str35 & "," & str36 & "," & str37 & "," & str38 & "," & str39 & "," & str40 sql_qry9 = "," & str41 & "," & str42 & "," & str43 & "," & str44 & "," & str45 & "," & str46 & "," & str47 & "," & str48 & ",'" & str49 & "')" strok = sql_qry & sql_qry1 & sql_qry2 & sql_qry3 & sql_qry4 & sql_qry5 & sql_qry6 & sql_qry7 & sql_qry8 & sql_qry9 Dim strok2 As String strok2 = "insert into tblWELL_TEST_GASCONDENSAT (UWI,Unique_Test_ID,Unique_Mode_ID) values('" & str1 & "','" & str2 & "','" & str3 & "')" cnn.Execute strok Next I cnn.Close End Sub
Помогите понять причину.
Решение задачи: «Запись из excel в acces скриптом vba»
textual
Листинг программы
Parametr_sqrt(Tzp)
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д