关于把excel文件中的数据转入sql数据表中的问题
代码如下:(好像发现数据交错问题,就是行和行之间的数据有交错问题)
Dim myDataSet As DataSet = New DataSet
Dim ConnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\2006.xls;Extended Properties=Excel 8.0 "
Dim query As String = "SELECT * FROM [worksheet$] "
Dim oleCommand As OleDbCommand = New OleDbCommand(query, New OleDbConnection(ConnStr))
Dim oleAdapter As OleDbDataAdapter = New OleDbDataAdapter(oleCommand)
oleAdapter.Fill(myDataSet, "product ")
Dim tb1 as datatable
tb1=mydataset.tables( "product ")
Dim drow as datarow
for each drow in tb1.rows
Dim con as sqlconnection
Dim cmd as sqlcommand
Dim strcmd as string
con=new sqlconnection(ConfigurationSettings.AppsettingS( "cp "))
strcmd= "insert product (Vid,Vendorname,TIIitem,FactoryitemID,Description,Producth,ProductW,ProductL,UM,Bag,Inners,MID,Cases,tcbm,Cuft,Fob,DutyP,DutyD,OtherFeeD,TotalFob,Lec,Lwc,P1,FSP,DifftoP1,LwctoP1,Fobadd,Loadingport,LT,Moqpcs,CaseDimensioncmL,CaseDimensioncmW,CaseDimensioncmH,InnerDimensioncmL,InnerDimensioncmW,InnerDimensioncmH,GROSSWEIGHTkg,GROSSWEIGHTLbs,M1,M2,M3,CaseDimensionInchL,CaseDimensionInchW,CaseDimensionInchH,InnerDimensionInchL,InnerDimensionInchW,InnerDimensionInchH) values (@Vid,@Vendorname,@TIIitem,@FactoryitemID,@Description,@Producth,@ProductW,@ProductL,@UM,@Bag,@Inners,@MID,@Cases,@tcbm,@Cuft,@Fob,@DutyP,@DutyD,@OtherFeeD,@TotalFob,@Lec,@Lwc,@P1,@FSP,@DifftoP1,@LwctoP1,@Fobadd,@Loadingport,@LT,@Moqpcs,@CaseDimensioncmL,@CaseDimensioncmW,@CaseDimensioncmH,@InnerDimensioncmL,@InnerDimensioncmW,@InnerDimensioncmH,@GROSSWEIGHTkg,@GROSSWEIGHTLbs,@M1,@M2,@M3,@CaseDimensionInchL,@CaseDimensionInchW,@CaseDimensionInchH,@InnerDimensionInchL,@InnerDimensionInchW,@InnerDimensionInchH) "
cmd=new sqlcommand(strcmd,con)
cmd.parameters.add( "@vid ",sqldbtype.varchar).value=drow( "vid ")
cmd.parameters.add( "@vendorname ",sqldbtype.varchar).value=drow( "vendorname ")
cmd.parameters.add( "@tiiitem ",sqldbtype.varchar).value=drow( "tiiitem ")
cmd.parameters.add( "@factoryitemid ",sqldbtype.varchar).value=drow( "factoryitemid ")
cmd.parameters.add( "@description ",sqldbtype.varchar).value=drow( "description ")
cmd.parameters.add( "@producth ",sqldbtype.varchar).value=drow( "producth ")
cmd.parameters.add( "@productw ",sqldbtype.varchar).value=drow( "productw ")
cmd.parameters.add( "@productl ",sqldbtype.varchar).value=drow( "productl ")
cmd.parameters.add( "@um ",sqldbtype.varchar).value=drow( "u/m ")
cmd.parameters.add( "@bag ",sqldbtype.varchar).value=drow( "bag ")
cmd.parameters.add( "@inners ",sqldbtype.varchar).value=drow( "inner ")
cmd.parameters.add( "@Mid ",sqldbtype.varchar).value=drow( "Mid ")
cmd.parameters.add( "@cases ",sqldbtype.varchar).value=drow( "case ")
cmd.parameters.add( "@tcbm ",sqldbtype.varchar).value=drow( "tcbm ")
cmd.parameters.add( "@cuft ",sqldbtype.varchar).value=drow( "cuft ")
cmd.parameters.add( "@fob ",sqldbtype.varchar).value=drow( "fob ")
cmd.parameters.add( "@dutyp ",sqldbtype.varchar).value=drow( "Duty % ")