|
-
Mar 1st, 2004, 06:07 AM
#1
Thread Starter
Junior Member
assigning a database value to a string.
hi...
can someone tell me how do i assign a value to a string to do further processing...so far i've done this
Code:
oleDbDonnection1.Open();
oleDbDataAdapter.SelectCommand.CommandText = ......
string UserType = (string) oleDbDataAdapter.SelectCommand.ExecuteScalar(); // is this correct...the usertype column is not the first column its the third column...
UserType.ToString();
-
Mar 1st, 2004, 07:48 AM
#2
Addicted Member
i dont know much about ado .net but wouldnt you fill a dataset an pull the value from it?
-
Mar 1st, 2004, 10:05 AM
#3
PowerPoster
ExecuteScalar only returns one value, which is the first value in the first row of the result set that is returned from the query.
So, if what you want is the third value in your query, you will never get it with ExecuteScalar.
Either adjust your CommandText to get just the one value, or you need to ExecuteReader or ExecuteDataset and manually map to the column you are looking for.
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
|