|
-
Dec 9th, 2009, 04:06 AM
#1
Thread Starter
Addicted Member
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.
-
Dec 9th, 2009, 04:17 AM
#2
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.
-
Dec 9th, 2009, 04:24 AM
#3
Thread Starter
Addicted Member
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.
-
Dec 9th, 2009, 04:25 AM
#4
Thread Starter
Addicted Member
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.
-
Dec 9th, 2009, 04:32 AM
#5
Thread Starter
Addicted Member
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.
-
Dec 9th, 2009, 04:39 AM
#6
Re: DataSet Question
You may bow in a pissed off manner. Everything's easy when you know how.
-
Dec 9th, 2009, 04:43 AM
#7
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|