thread796-528768
The above thread describes a method called SQL-Loader that is able to quickly import large text file (more than 10,000 linee) into an .mdb. I am trying to accomplish this but I am getting an error that states, "No value given for one or more required parameters." The file is fixedlength. Each line is over 200 characters long and gets split into 76 different fields. I am able to buffer the entire file and the bring it in one line at a time, but this is slow. Here is my code:
Dim connstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\text\Import2DB.MDB;"
Dim conn As OleDbConnection = New OleDbConnection(connstring)
conn.Open()
Dim cmd1 As New OleDbCommand("INSERT INTO maintbl " _
& "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10" _
& ",F11,F12,F13,F14,F15,F16,F17,F18,F19,F20" _
& ",F21,F22,F23,F24,F25,F26,F27,F28,F29,F30" _
& ",F31,F32,F33,F34,F35,F36,F37,F38,F39,F40" _
& ",F41,F42,F43,F44,F45,F46,F47,F48,F49,F50" _
& ",F51,F52,F53,F54,F55,F56,F57,F58,F59,F60" _
& ",F61,F62,F63,F64,F65,F66,F67,F68,F69,F70" _
& ",F71,F72,F73,F74,F75,F76) " _
& "SELECT col1,col2,col3,col4,col5,col6,col7,col8,col9,col10," _
& "col11,col12,col13,col14,col15,col16,col17,col18,col19,col20," _
& "col21,col22,col23,col24,col25,col26,col27,col28,col29,col30," _
& "col31,col32,col33,col34,col35,col36,col37,col38,col39,col40," _
& "col41,col42,col43,col44,col45,col46,col47,col48,col49,col50," _
& "col51,col52,col53,col54,col55,col56,col57,col58,col59,col60," _
& "col61,col62,col63,col64,col65,col66,col67,col68,col69,col70," _
& "col71,col72,col73,col74,col75,col76 FROM " _
& "[TEXT;Database=C:\text\;HDR=NO;Format=FixedLength;" _
& "col1=F1 Text Width 6;col2=F2 Text Width 6;col3=F3 Text Width 2;" _
& "col4=F4 Text Width 10;col5=F5 Text Width 3;col6=F6 Text Width 2;" _
& "col7=F7 Text Width 10;col8=F8 Text Width 1;col9=F9 Text Width 4;" _
& "col10=F10 Text Width 1;col11=F11 Text Width 4;col12=F12 Text Width 1;" _
& "col13=F13 Text Width 1;col14=F14 Text Width 1;col15=F15 Text Width 1;" _
& "col16=F16 Text Width 1;col17=F17 Text Width 6;col18=F18 Text Width 7;" _
& "col19=F19 Text Width 2;col20=F20 Text Width 2;col21=F21 Text Width 3;" _
& "col22=F22 Text Width 3;col23=F23 Text Width 2;col24=F24 Text Width 1;" _
& "col25=F25 Text Width 1;col26=F26 Text Width 1;col27=F27 Text Width 1;" _
& "col28=F28 Text Width 1;col29=F29 Text Width 1;col30=F30 Text Width 1;" _
& "col31=F31 Text Width 1;col32=F32 Text Width 1;col33=F33 Text Width 1;" _
& "col34=F34 Text Width 1;col35=F35 Text Width 1;col36=F36 Text Width 1;" _
& "col37=F37 Text Width 1;col38=F38 Text Width 1;col39=F39 Text Width 1;" _
& "col40=F40 Text Width 1;col41=F41 Text Width 1;col42=F42 Text Width 1;" _
& "col43=F43 Text Width 1;col44=F44 Text Width 1;col45=F45 Text Width 1;" _
& "col46=F46 Text Width 2;col47=F47 Text Width 6;col48=F48 Text Width 3;" _
& "col49=F49 Text Width 1;col50=F50 Text Width 1;col51=F51 Text Width 1;" _
& "col52=F52 Text Width 1;col53=F53 Text Width 1;col54=F54 Text Width 1;" _
& "col55=F55 Text Width 1;col56=F56 Text Width 1;col57=F57 Text Width 1;" _
& "col58=F58 Text Width 1;col59=F59 Text Width 10;col60=F60 Text Width 3;" _
& "col61=F61 Text Width 2;col62=F62 Text Width 4;col63=F63 Text Width 2;" _
& "col64=F64 Text Width 2;col65=F65 Text Width 1;col66=F66 Text Width 2;" _
& "col67=F67 Text Width 1;col68=F68 Text Width 7;col69=F69 Text Width 10;" _
& "col70=F70 Text Width 4;col71=F71 Text Width 1;col72=F72 Text Width 10;" _
& "col73=F73 Text Width 4;col74=F74 Text Width 1;col75=F75 Text Width 4;" _
& "col76=F76 Text Width 20].[" & FileListBox1.FileName & "]", conn)
cmd1.ExecuteNonQuery()
conn.Close()
Is the problem that my query is too long?
Help please.
Karl
The above thread describes a method called SQL-Loader that is able to quickly import large text file (more than 10,000 linee) into an .mdb. I am trying to accomplish this but I am getting an error that states, "No value given for one or more required parameters." The file is fixedlength. Each line is over 200 characters long and gets split into 76 different fields. I am able to buffer the entire file and the bring it in one line at a time, but this is slow. Here is my code:
Dim connstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\text\Import2DB.MDB;"
Dim conn As OleDbConnection = New OleDbConnection(connstring)
conn.Open()
Dim cmd1 As New OleDbCommand("INSERT INTO maintbl " _
& "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10" _
& ",F11,F12,F13,F14,F15,F16,F17,F18,F19,F20" _
& ",F21,F22,F23,F24,F25,F26,F27,F28,F29,F30" _
& ",F31,F32,F33,F34,F35,F36,F37,F38,F39,F40" _
& ",F41,F42,F43,F44,F45,F46,F47,F48,F49,F50" _
& ",F51,F52,F53,F54,F55,F56,F57,F58,F59,F60" _
& ",F61,F62,F63,F64,F65,F66,F67,F68,F69,F70" _
& ",F71,F72,F73,F74,F75,F76) " _
& "SELECT col1,col2,col3,col4,col5,col6,col7,col8,col9,col10," _
& "col11,col12,col13,col14,col15,col16,col17,col18,col19,col20," _
& "col21,col22,col23,col24,col25,col26,col27,col28,col29,col30," _
& "col31,col32,col33,col34,col35,col36,col37,col38,col39,col40," _
& "col41,col42,col43,col44,col45,col46,col47,col48,col49,col50," _
& "col51,col52,col53,col54,col55,col56,col57,col58,col59,col60," _
& "col61,col62,col63,col64,col65,col66,col67,col68,col69,col70," _
& "col71,col72,col73,col74,col75,col76 FROM " _
& "[TEXT;Database=C:\text\;HDR=NO;Format=FixedLength;" _
& "col1=F1 Text Width 6;col2=F2 Text Width 6;col3=F3 Text Width 2;" _
& "col4=F4 Text Width 10;col5=F5 Text Width 3;col6=F6 Text Width 2;" _
& "col7=F7 Text Width 10;col8=F8 Text Width 1;col9=F9 Text Width 4;" _
& "col10=F10 Text Width 1;col11=F11 Text Width 4;col12=F12 Text Width 1;" _
& "col13=F13 Text Width 1;col14=F14 Text Width 1;col15=F15 Text Width 1;" _
& "col16=F16 Text Width 1;col17=F17 Text Width 6;col18=F18 Text Width 7;" _
& "col19=F19 Text Width 2;col20=F20 Text Width 2;col21=F21 Text Width 3;" _
& "col22=F22 Text Width 3;col23=F23 Text Width 2;col24=F24 Text Width 1;" _
& "col25=F25 Text Width 1;col26=F26 Text Width 1;col27=F27 Text Width 1;" _
& "col28=F28 Text Width 1;col29=F29 Text Width 1;col30=F30 Text Width 1;" _
& "col31=F31 Text Width 1;col32=F32 Text Width 1;col33=F33 Text Width 1;" _
& "col34=F34 Text Width 1;col35=F35 Text Width 1;col36=F36 Text Width 1;" _
& "col37=F37 Text Width 1;col38=F38 Text Width 1;col39=F39 Text Width 1;" _
& "col40=F40 Text Width 1;col41=F41 Text Width 1;col42=F42 Text Width 1;" _
& "col43=F43 Text Width 1;col44=F44 Text Width 1;col45=F45 Text Width 1;" _
& "col46=F46 Text Width 2;col47=F47 Text Width 6;col48=F48 Text Width 3;" _
& "col49=F49 Text Width 1;col50=F50 Text Width 1;col51=F51 Text Width 1;" _
& "col52=F52 Text Width 1;col53=F53 Text Width 1;col54=F54 Text Width 1;" _
& "col55=F55 Text Width 1;col56=F56 Text Width 1;col57=F57 Text Width 1;" _
& "col58=F58 Text Width 1;col59=F59 Text Width 10;col60=F60 Text Width 3;" _
& "col61=F61 Text Width 2;col62=F62 Text Width 4;col63=F63 Text Width 2;" _
& "col64=F64 Text Width 2;col65=F65 Text Width 1;col66=F66 Text Width 2;" _
& "col67=F67 Text Width 1;col68=F68 Text Width 7;col69=F69 Text Width 10;" _
& "col70=F70 Text Width 4;col71=F71 Text Width 1;col72=F72 Text Width 10;" _
& "col73=F73 Text Width 4;col74=F74 Text Width 1;col75=F75 Text Width 4;" _
& "col76=F76 Text Width 20].[" & FileListBox1.FileName & "]", conn)
cmd1.ExecuteNonQuery()
conn.Close()
Is the problem that my query is too long?
Help please.
Karl