DataGrid不会填充VB6(SQL,ADODB)

时间:2014-02-16 01:37:57

标签: sql datagrid vb6 adodb recordset

我正在尝试用我的表中的数据填充我的数据网格,但除了列名之外它绝对没有显示,这是我的代码:

Private Sub Form_Load()


 Dim con As New ADODB.Connection
 Dim rsGrid As New ADODB.recordset
 Dim conString As String
 Dim sql As String

 conString = "Provider=SQLNCLI10;Server=mySv;Database=MyDb;Trusted_Connection=yes"
 con.Open conString

 rsGrid.CursorLocation = adUseClient
 Set DataGrid1.DataSource = Nothing

 sql = "select*from tbdRandom"
 rsGrid.Open sql, con 'already tried adCmdText and stuff like that
 Set DataGrid1.DataSource = rsGrid
 rsGrid.Requery

 End Sub

无论如何,提前谢谢

0 个答案:

没有答案