我正在尝试使用以下连接字符串连接到SQL Server Compact Edition .sdf文件;
connMRC.ConnectionString = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=" & App.Path & "\Freeweigh.sdf;"
每次尝试运行SQL命令或打开记录集时,我都会收到以下错误:
多步OLE DB生成的错误。检查每个OLE DB状态值(如果可用)。没有工作。
我正在使用VB 6.0和SQL Server Compact 3.5 SP2
以下是代码:
Public Sub opnConnectionC()
'Code for opening the ADO Connection
chkConn = connMRC.State
If chkConn = adStateClosed Then
connMRC.ConnectionString = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=" & App.Path & "\Freeweigh.sdf;"
connMRC.Open
End If
End Sub
Public Sub opnRecordsetC(rsOpen As Recordset)
'Code for opening the ADO Recordset
chkRs = rsOpen.State
If chkRs = adStateClosed Then
rsOpen.Source = strSQLC
rsOpen.CursorType = adOpenDynamic
rsOpen.LockType = adLockOptimistic
rsOpen.ActiveConnection = connMRC
rsOpen.Open
End If
End Sub
Private Sub tmrUpload_Timer()
Dim cmdUpload As New ADODB.Command
Dim rsFetch As New ADODB.Recordset
Call opnConnectionC
strSQLC = "SELECT Product FROM VehicleWeights"
Call opnRecordsetC(rsFetch)
rsFetch.MoveFirst
MsgBox (rsFetch.Fields("Product").Value)
Call clsConnectionC
End Sub
答案 0 :(得分:0)
您只能打开仅向前,只读记录集