为什么VB6 TDBGRID绑定老是没有数据呢?
我是新手。在做一个VB6网格绑定代码如下,网格对象那边字段有些(DataFiled)。adodata 对象为ADODC那个分页的东西
Dim ado_reset As New ADODB.Recordset
Public Sub Form_Load()[local]1[/local]
Dim fos As New FileSystemObject
Dim xmlDoc As New DOMDocument
Dim xmlName As IXMLDOMElement
Dim xmlAge As IXMLDOMElement
Dim xmlSex As IXMLDOMElement
Dim xmlInfo As IXMLDOMElement
Dim xmlRoot As IXMLDOMNode
Dim xmlSelectInfo As IXMLDOMNodeList
InitGrid
CreateData
ado_reset.AddNew
ado_reset.Fields("number").Value = "1"
ado_reset.Fields("age").Value = 16
ado_reset.Fields("name").Value = "1"
ado_reset.Fields("易做图").Value = 1
ado_reset.Update
Set adodata.Recordset = ado_reset
'gridInfo.Recordset = ado_reset
End Sub
Private Sub InitGrid()
With gridInfo
Set .DataSource = adodata
.SelectedBackColor = g_clrSelectedBack
.SelectedForeColor = g_clrSelectedFore
End With
End Sub
'创建手动数据集
Private Sub CreateData()
Set ado_reset = New ADODB.Recordset
ado_reset.CursorType = adOpenDynamiRecordsetc
ado_reset.LockType = adLockOptimistic
ado_reset.CursorLocation = adUseClient
ado_reset.Fields.Append "number", adChar, 2
ado_reset.Fields.Append "age", adChar, 4
ado_reset.Fields.Append "name", adVarChar, 6
ado_reset.Fields.Append "易做图", adVarChar, 4
ado_reset.Open
End Sub
不知道为什么界面一直没有数据 水都没人水,我擦 由于控件有多种类型,代码完全没有问题,需要选择OLEDB 控件就可以了
补充:VB , 基础类