在此处输入图像描述我在 vb.net 中使用 SQL Server Compact 3.5 数据库文件 (.sdf)
解析查询时出错。[令牌行号,令牌行偏移量,,令牌错误,,]
Dim flag As Boolean
Dim flag2 As Boolean
Me.OpenFileDialog1.Filter = "mdb files (*.mdb)|"
Me.OpenFileDialog1.Filter = "mdb files (*.mdb)|*.mdb|All files (*.*)|*.*"
flag2 = (Me.OpenFileDialog1.ShowDialog() = DialogResult.OK)
If flag2 Then
flag = (Operators.CompareString(FileSystem.Dir(Me.OpenFileDialog1.FileName, FileAttribute.Normal), "", False) <> 0)
End If
Dim myConnectionStringMDB As String = "provider=Microsoft.Ace.OLEDB.12.0;" & "data source=" & Me.OpenFileDialog1.FileName
Dim myConnectionStringSQL As String = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;" & "Data Source=" & Application.StartupPath & "\Archive.sdf"
Using conSQL As OleDbConnection = New OleDbConnection(), conMDB As OleDbConnection = New OleDbConnection()
conSQL.ConnectionString = myConnectionStringSQL
conSQL.Open()
conMDB.ConnectionString = myConnectionStringMDB
conMDB.Open()
Using cmdSQL As OleDbCommand = New OleDbCommand(), cmdMDB As OleDbCommand = New OleDbCommand()
cmdMDB.CommandType = Data.CommandType.Text
cmdMDB.Connection = conMDB
cmdMDB.CommandText = "SELECT * FROM [student]"
Dim daMDB = New System.Data.OleDb.OleDbDataAdapter(cmdMDB)
Dim dt = New Data.DataTable()
daMDB.Fill(dt)
For Each dr As Data.DataRow In dt.Rows
' change row status from "Unchanged" to "Added" so .Update below will insert them
dr.SetAdded()
Next
cmdSQL.CommandType = Data.CommandType.Text
cmdSQL.Connection = conSQL
cmdSQL.CommandText = "SELECT * FROM [student]"
Dim daSQL = New System.Data.OleDb.OleDbDataAdapter(cmdSQL)
Dim cbuilderMDB = New OleDbCommandBuilder(daSQL)
cbuilderMDB.QuotePrefix = "["
cbuilderMDB.QuoteSuffix = "]"
daSQL.Update(dt)
End Using
conSQL.Close()
conMDB.Close()
End Using