我有一个使用ADODB 2.8连接到 SQL Server 服务器的 VB6 应用程序。我已经声明了绑定和记录集。信息显示正确。不过,当我尝试更新任何字段时,我收到一条错误消息:
绑定集合错误
字段不可更新,绑定属性名称:文本,字段名称:DTMOUVEMEN
我很确定这与创建 ADODB.Recorset 的方式有关,但我不知道,VB6 不是我的专业领域。
我的表单中绑定到 ADODC 的文本框是这样的
Begin VB.TextBox DTMOUVEMENT
BackColor = &H00E0E0E0&
DataField = "DTMOUVEMEN"
DataSource = "DataTYPEMOUVEMENTADO"
Height = 315
Left = 2820
Locked = -1 'True
TabIndex = 1
TabStop = 0 'False
Text = "DTMOUVEMENT"
Top = 2820
Width = 2895
End
ADODC 组件是这样定义的
Begin MSAdodcLib.Adodc DataTYPEMOUVEMENTADO
Height = 330
Left = 5800
Top = 2500
Width = 2295
_ExtentX = 4048
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "DataTYPEMOUVEMENTADO"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
ADODC 组件是这样绑定的
strSQL = "here goes the sql query"
Set adoRS = New ADODB.Recordset
With adoRS
.CursorLocation = adUseServer
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open strSQL, adoDbConn
End With
Set Me.DataTYPEMOUVEMENTADO.Recordset = adoRS
连接是这样定义的
Set adoDbConn = New ADODB.Connection
' Specify the OLE DB provider.
adoDbConn.Provider = "sqloledb"
adoDbConn.Mode = adModeReadWrite
adoDbConn.Open "connection string data"