datagrid error: no such interface supported
Hi,
I came across an error while I was trying to bind a recorset to a datagrid.
You can read the code of my subroutine above.
I'm able to open the recordset but when I try to set the datasource of my Datagrid (NameGrid) an error occurs.
I can see this error only in MyConnection.Errors.
The error description is "no such interface supported"
Native Error:-2147467262
Number:-2147467262
Source:Provider
SQLState:""
The strange thing is that if I set the datasource immediatly before opening the recordset and then I execute a requery (see Solution 2) no error occurs.
Can anyone give me some advice ?
Thank you
Private Sub Form_Load()
Dim Cmd As New ADODB.Command
Dim ret_code As Integer
Dim par_recordset As New ADODB.Recordset
Dim SQLQuery As String
With par_recordset
.ActiveConnection = MyConnection
.LockType = adLockOptimistic
.CursorType = adOpenStatic
End With
SQLQuery = "SELECT * FROM MyTable"
Set Cmd.ActiveConnection = MyConnection
Cmd.CommandText = SQLQuery
Cmd.CommandType = adCmdText
Solution 1
par_recordset.Open Cmd
Set NameGrid.DataSource = par_recordset
Solution 2
Set NameGrid.DataSource = par_recordset
par_recordset.Open Cmd
par_recordset.Requery
End Sub