Dim dlg As New OpenFileDialog
dlg.Filter = "Excel|*.xls;*.xlsx;*.csv"
Dim sfz As Integer
Dim xjh As Integer
If dlg.ShowDialog = DialogResult.OK Then
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.connectionname =
cmd.CommandText = "SE LECT 身份证件号,学籍号,就读学校,班级 From {学生台帐}"
dt = cmd.ExecuteReader()
Dim Book As New XLS.Book(dlg.filename)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For i As Integer=0 To sheet.Cols.Count-1
If sheet(0,i).Value="身份证件号"
sfz =i
End If
If sheet(0,i).value="学籍号"
xjh=i
End If
Next
Dim dr1 As DataRow
Dim dr As DataRow
For n As Integer = 1 To Sheet.Rows.Count -1
dr1 = dt.find("身份证件号='" & sheet(n,sfz).value & "' and 就读学校='" & _usergroup & "'")
If dr1 Is Nothing
dr = DataTables("学生台帐").Addnew()
End If
For m As Integer = 0 To sheet.Cols.count -1
dr(sheet(0,m).value)=sheet(n,m).value
dr("就读学校")=_usergroup
dr("所属中心校")=sszxx
Next
Next
End If
Tables("学生台帐_table1").save()
把这个保存放在导入按钮中,应该可以执行保存,但不行,但单独用同样命令做一个保存就可以呢,之前没见过这种情况