关二VB6中DataGrid控件绑定的问题.
请看下面代码标志, 为啥数据库关闭了, DataGrid就是空白的. 绑定不到数据. 如果没有这二行. 不关闭数据库就可以, 有人知道怎回事? 难道VB6里面与里面的绑定不同? 太久没写VB6的了, 请高手指点. 不关闭的对数据库影响好大呀Dim con As New ADODB.Connection, rs As New ADODB.Recordset, com As New
Dim SqlConString As String, SqlStr As String, Row As Integer, Col As Integer
SqlConString = "provider=sqloledb;data source=james\sql2000;user id=sa;password=;initial catalog=unistardb"
con.Open (SqlConString)
If con.State = 1 Then
SqlStr = "select * from dbo.operator"
rs.Open SqlStr, con, 3, 2
Set fpSpread1.DataSource = rs
Set DataGrid1.DataSource = rs '这里是绑定
' For Row = 1 To rs.RecordCount
' For Col = 1 To rs.Fields.Count
' fpSpread1.Row = 1
' fpSpread1.Col = 1
' fpSpread1.Text = rs.Fields(0)
' Next Col
' Next Row
rs.Close '这二行是关闭
con.Close
Else
MsgBox "数据库没有连接!"
End
End If