|
-
Nov 8th, 2001, 11:47 AM
#1
Thread Starter
New Member
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
Last edited by calzolani; Nov 8th, 2001 at 11:52 AM.
-
Nov 9th, 2001, 09:01 AM
#2
How about something like this:
Code:
dim rs as new adodb.recordset
dim strSQL as string
strSQL = "SELECT * FROM MyTable"
rs.Open strsql, MyConnection, adOpenKeyset, adLockOptimistic
if rs.eof = false and rs.bof = false then
Set NameGrid.DataSource = rs
end if
-
Nov 9th, 2001, 12:26 PM
#3
Thread Starter
New Member
Thank you for answering me,
I modified my code but it doesn't work.
In my message I forgot to write that ,as for solution 1,my subroutine works actually.
In fact, the datagrid displays all the rows of the table immediatly after the error.
The problem is that I developed an error handler that traps every error and raises a message box and I would like to raise no message concerning the error I mentioned.
Of course I could test the error code and decide not to display any message but I don't believe this is the best solution.
So, I would like to know the reason why the error comes out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|