Results 1 to 7 of 7

Thread: DataSet Question

  1. #1

    Thread Starter
    Addicted Member Abrium's Avatar
    Join Date
    Feb 2007
    Location
    The Great State of Texas
    Posts
    205

    Question DataSet Question

    Once I have filled a dataset is there a set of properties or in-line functions that will allow me to pull the data out of said dataset without having to populate a datagrid?

    Code example:
    Code:
            Connection.Open()
            accCommand.CommandText = "SELECT CustID FROM Rental WHERE DvdID = " & DvdID
            accCommand.Connection = Connection
            dvdDataAdapter.SelectCommand = accCommand
            accCommand.ExecuteNonQuery()
            dvdDataAdapter.Fill(dvdDataSet, "CustID")
            Connection.Close()
    I know the information returned from the query is a single value located at (0, 0) I just can't get to it so I can assign the value to the variable. I wouldn't be doing this if I could nail down the syntax for a nested query in Access 2007. Any suggestions?

    Thanks guys.
    Abrium
    Asking the beginners questions so you don't have to!
    If by chance hell actually froze over and I some how helped you... Please rate.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: DataSet Question

    There are various ways you can get specific data out of a DataSet but if all you're getting from the database is a single value then you shouldn't be putting it in a DataSet in the first place. Follow the CodeBank link in my signature and check out my thread on Retrieving and Saving Data. Take a look at the type of code that's appropriate for each scenario and notice that for your scenario you should be call ExecuteScalar.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member Abrium's Avatar
    Join Date
    Feb 2007
    Location
    The Great State of Texas
    Posts
    205

    Re: DataSet Question

    ExecuteScalar looks to be exactly what I need. And... I used the dataset because that is actually what I was instructed to use. You have to remember that each time I ask a question on here I'm breaking new ground JM. I whole heartedly appreciate your knowledge as well as your prompt responses.

    I'm going to toy with ExecuteScalar, I don't exactly know how to use it and your syntax somewhat confused me.

    Thanks again man.
    Abrium
    Asking the beginners questions so you don't have to!
    If by chance hell actually froze over and I some how helped you... Please rate.

  4. #4

    Thread Starter
    Addicted Member Abrium's Avatar
    Join Date
    Feb 2007
    Location
    The Great State of Texas
    Posts
    205

    Re: DataSet Question

    I mean do I need to specify a table in here somewhere?

    Code:
    Dim totalQuantity As Double = CDbl(command.ExecuteScalar())
    Abrium
    Asking the beginners questions so you don't have to!
    If by chance hell actually froze over and I some how helped you... Please rate.

  5. #5

    Thread Starter
    Addicted Member Abrium's Avatar
    Join Date
    Feb 2007
    Location
    The Great State of Texas
    Posts
    205

    Re: DataSet Question

    No freakin way, I just want to carry you around with me, sometimes you amaze me and yet piss me off so bad. Its not as if I don't research prior to posting here, I usually put a good half hour to hour into a problem before I come here and I don't know whether to bow to you or just be more pissed at the ease in which you solve my trivial issues lol!

    Code:
            Connection.Open()
            accCommand.CommandText = "SELECT CustID FROM Rental WHERE DvdID = " & DvdID
            accCommand.Connection = Connection
            dvdDataAdapter.SelectCommand = accCommand
            accCommand.ExecuteNonQuery()
            Dim Customer As Integer = CInt(accCommand.ExecuteScalar)
            Connection.Close()
    Abrium
    Asking the beginners questions so you don't have to!
    If by chance hell actually froze over and I some how helped you... Please rate.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: DataSet Question

    You may bow in a pissed off manner. Everything's easy when you know how.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Addicted Member Abrium's Avatar
    Join Date
    Feb 2007
    Location
    The Great State of Texas
    Posts
    205

    Re: DataSet Question

    God you aren't lyin!
    Abrium
    Asking the beginners questions so you don't have to!
    If by chance hell actually froze over and I some how helped you... Please rate.

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