我有一个VB6应用程序,该应用程序通过使用 ADODB 2.8 连接到SQL Server服务器。我已经声明了绑定和记录集。信息显示正确。不过,当我尝试更新任何字段时,都会收到一条错误消息:
绑定收集错误
字段不可更新,绑定属性名称:文本,字段名称: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"
答案 0 :(得分:0)
好的,所以我发现了错误。对于这种特殊情况,SQL查询定义错误,因此在Adodc记录集中未设置任何字段 DTMOUVEMEN 。