Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2003, 10:51 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bindind data-bound grids to ADO recordsets

I am having trouble setting the datasource property of the ADO grid control or the DataGrid control to a recordset, here is the situation.

Due to project limitations, I am not able to use a data control and then bind the grids to the actual data control. I've used the Active Data Objects(ADO) reference, (click project/references and put a checkc next to it). then fed the connection a conneectoin string, that all goes fine...then dim'd a recordset and gave it a valid SQL string. it returns the recordset properly, i tested it and it is getting the right data...the problem lies here.

I want to bind the recordset to a datagrid control(any of them)...but the datagrid controls only seem to want to be bound to actual data controls you draw on the form..(like the generic data control, or the ADO data control)...not the populated recordset.

I'm using "Microsoft DataGrid Control 6.0(sp5)"...attemping to bind it to a recordset created from the ADO reference, this is the error message I'm receiving:

Method or data member not found.

it's not expecting to receive a recordset like that.. if this helps, here is the prelimary code:
("rS" is a valid recordset btw)

rS.Open "SELECT * FROM INVENTORY", cOn, adOpenDynamic, adLockOptimistic, adCmdText
rS.MoveFirst
DataGrid1.DataSource = rS

bam...error right there. Anyone have any suggestions? Or perhaps know of a dataGrid control that will accecpt recordsets? Any help would really be appreciated.

~hunter
 
Old June 19th, 2003, 11:05 PM
n/a
Guest
 
Posts: n/a
Default

I do this all the time with Sherdian data grid

Try

set datagrid1.datasource = rs

since you are dealing with an object, use have to use the set keyword
 
Old June 19th, 2003, 11:08 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried that earlier tonight =o( I got an error I didn't understand, "the recordset is not bookmarkable" =o( Any experience with this?
 
Old June 19th, 2003, 11:14 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Shouldn't that be:

Set DataGrid1.DataSource = rS

I think you have to use the 'set' command to set the datasource property to the reference to the recordset.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old June 19th, 2003, 11:17 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ack, sorry fellows. It was another error, my own mistake...trying to code while too tired. I had cut and pasted the code from an earlier project, and must have missed the line where i was setting cursorlocations... I figured it out when i just ran the old code and it worked..compared line by line until I found what I missed in my sleeplessness, thanks for all the help though ;]





Similar Threads
Thread Thread Starter Forum Replies Last Post
"Proper" way of updating bound controls and grids VBM2 Pro Visual Basic 2005 1 March 12th, 2007 09:36 AM
Creating/Populating Recordsets in ADO dgulliver VB How-To 3 May 24th, 2006 03:31 AM
Nesting ADO recordsets yossarian Pro VB Databases 1 January 12th, 2005 06:28 PM
Data grids ?????? Louisa Beginning VB 6 1 November 18th, 2003 04:39 AM
Data Grids Louisa Beginning VB 6 1 October 17th, 2003 03:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.