Results 1 to 4 of 4

Thread: Having trouble with the simplest thing

  1. #1

    Thread Starter
    Addicted Member P.S.W.'s Avatar
    Join Date
    Aug 2000
    Posts
    146

    Unhappy

    I'm trying to switch over from using the ADO control in my project to creating the ADO recordsets purely in code.

    So I'm trying to link such a recordset, created from code, to my controls, namely an MSChart and a DataGrid:

    dbRecordset.Open ("SELECT Quantity FROM Table1"), dbConnection

    (recordset & connection variables are already defined)

    Set MSChart1.DataSource = dbRecordset
    Set Datagrid1.DataSource = dbRecordset

    Problem #1: My MSChart shows up _completely_ blank. I mean not even the axes or anything shows up.

    Problem #2: My DataGrid slaps me with an error saying "Error 7004 - The rowset is not bookmarkable"


    What am I doing wrong?


  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Although I cannot answer your questions directly there are a lot of questions about DataGrid and MSChart controls on this forum. I would suggest you do a search on 'DataGrid' and 'MSChart' using the search facility above as there are many who have had the same questions as you. Here are a couple of links to threads that WILL help you with the datagrid.

    http://forums.vb-world.net/showthrea...threadid=26564
    http://forums.vb-world.net/showthrea...threadid=26740

    Happy Reading


    Things I do when I am bored: DotNetable

  3. #3
    Member
    Join Date
    Aug 2000
    Posts
    51

    There are some trouble shooting methods you should learn to use when switching from using data controls to using code. What I do when I have this problem is I put a command button on my form and in the command button click event I just have a message box command to show various properties in the recordset. I do this to figure out whether the problem is in the recordset or the way the control is bound to the recordset. Put some records in the table. Do a msgbox adors.recordcount (this will tell you if there is anything in the recordset), then try a msgbox adors.fields("fieldname") (this will give you the value of that field for the record that you are currently on. This usually helps me to figure out whether the recordset has been populated. Once that is out of the way you can focus on how you have bound the controls.

    You have the code,

    dbRecordset.Open ("SELECT Quantity FROM Table1"), dbConnection

    in your message. That looks like it would work, but you don't specify the type of recordset to return or the type of locking to use. By default you will be given a forward only recordset if you don't tell it otherwise. You may be getting the bookmark error because the forward only recordset may not support the use of bookmarks. I could be wrong on that one though.

    I'm sure you'll be able to find out the specific syntax of the ado recordset open method either in your VB online help or from microsoft.com.

    Try opening your recordset with a dynamic cursor or keyset cursor. The locking method you use won't matter now but you should you optimistic locking unless you have a good reason to use pessemistic locking.

    I think you've opened the recordset sucessfully, but there could be a problem with the cursor type. Try dynamic cursors. Try binding your data to a text box before you bind it to a chart or grid. There is a lot less that can go wrong binding to a text box. This should get you started in the right direction at least.

  4. #4

    Thread Starter
    Addicted Member P.S.W.'s Avatar
    Join Date
    Aug 2000
    Posts
    146

    Smile

    Guys,

    Thanks for your input. I investigated the use of cursors, as suggested, and found that it was the default "forward-only" cursor that was discombobulating the MSChart (it works fine w/ the other cursors). As for the DataGrid, the bookmark error goes away if I use the "keyset" cursor.

    Thanks again for your help!
    PSW


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width