MyCommand = New System.Data.OleDb.OleDbDataAdapter( _
"select * from [Sheet1$] where ID is null", MyConnection)
MyConnection.Open()
MyCommand.Fill(ds2, "tbl2")
MyConnection.Close()
Dim rows As Int32
rows = ds2.Tables("tbl2").Rows.Count
Dim n As Int32
For n = 0 To rows - 1
Dim newrow As DataRow = DataSet1.Tables("tbl1").NewRow
如果excel 中没有自动编号列,好办,直接导入除自动编号以外的其它列就可以了.
如果想使用excel中自动编号对应列的值,可以先把ID列的identity去掉,导完以后在加上identity.
或者用Sql:
SET IDENTITY_INSERT 表 ON
insert into 表(id,q其它字段) values(1,'...')