How to set DbGrid datasource to a recordset created w/ADODB.Command 
Author Message
 How to set DbGrid datasource to a recordset created w/ADODB.Command

I am using a ADODB.Command to call a stored procedure which returns a
recordset.  When I try to make this recordset the datasource for true dbGrid
6.0, it never shows any records.  By changing settings around, I've run into
bookmark errors, fetching backward errors, etc.

This is from a sample I'm trying:
    Dim cmd As New ADODB.Command
    Dim rs As New ADODB.Recordset
   cmd.ActiveConnection = "Provider = SQLOLEDB.1;Persist Security
Info=False;User ID=xx;Initial Catalog=Northwind;Data Source=SHELLY"
  cmd.CommandType = adCmdStoredProc
  cmd.CommandText = "SubQueries"
  rs.CursorLocation = adUseClient
  rs.CursorType = adOpenStatic
  rs.LockType = adLockPessimistic
  Set rs = cmd.Execute  'returns the recordset
  Set DataGrid1.DataSource = rs

I then get the error that the rowset is not bookmarkable.   Recordset rs
has several records and is not forwardonly.  Is there something I can set to
the command, the recordset and/or the grid??

Please help!

Shelly Parry



Sun, 25 Aug 2002 03:00:00 GMT
 How to set DbGrid datasource to a recordset created w/ADODB.Command

It could be that you need to rephrase things slightly. Try this

Dim cn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset

Set cn = New ADODB.Conncection
Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset

cn.ConnectionString = "Provider = SQLOLEDB.1;Persist Security" & _
  "Info=False;User ID=xx;Initial Catalog=Northwind;Data Source=SHELLY"
cn.CursorLocation = adUseClient

cmd.CommandType = adCmdStoredProc
cmd.CommandText = "SubQueries"

rs.Open cmd, cn, adOpenStatic, adLockPessimistic
DataGrid1.DataSource = rs  'Don't need the Set with Apex grid.

--
Andrew Grillage
http://vbdata.iwarp.com


Quote:
> I am using a ADODB.Command to call a stored procedure which returns a
> recordset.  When I try to make this recordset the datasource for true
dbGrid
> 6.0, it never shows any records.  By changing settings around, I've run
into
> bookmark errors, fetching backward errors, etc.

> This is from a sample I'm trying:
>     Dim cmd As New ADODB.Command
>     Dim rs As New ADODB.Recordset
>    cmd.ActiveConnection = "Provider = SQLOLEDB.1;Persist Security
> Info=False;User ID=xx;Initial Catalog=Northwind;Data Source=SHELLY"
>   cmd.CommandType = adCmdStoredProc
>   cmd.CommandText = "SubQueries"
>   rs.CursorLocation = adUseClient
>   rs.CursorType = adOpenStatic
>   rs.LockType = adLockPessimistic
>   Set rs = cmd.Execute  'returns the recordset
>   Set DataGrid1.DataSource = rs

> I then get the error that the rowset is not bookmarkable.   Recordset rs
> has several records and is not forwardonly.  Is there something I can set
to
> the command, the recordset and/or the grid??

> Please help!

> Shelly Parry




Mon, 26 Aug 2002 03:00:00 GMT
 How to set DbGrid datasource to a recordset created w/ADODB.Command
Thanks for trying to help, but someone else emailed with the solution that
worked.  I was missing the properties
  cmd.Properties("Bookmarkable").Value = True
  cmd.Properties("Scroll Backwards").Value = True
This solved the problem.


Mon, 26 Aug 2002 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Creating adodb.record from Adodb.recordset

2. How do I use an ADODB recordset as datasource for a DATAGRID element

3. Creating filtered recordsets with set command in VB6

4. Setting DBGrid DataSource at run-time

5. how to set recordset clone to second child level recordset in shape command

6. Connection Open command without setting up a ODBC user datasource

7. Set ADODB.Command.ActiveConnection = Conn

8. Problems setting ActiveConnection in ADODB.Command

9. DBCC command closes ADODB.RecordSet???????

10. ADODB.Command does not return a recordset from a stored procedure

11. How to set datasource with empty recordset

12. Setting MSFlexGrid Datasource property to a Recordset object.


 
Powered by phpBB® Forum Software