|
-
May 26th, 2004, 02:59 PM
#1
Thread Starter
Hyperactive Member
Dumb one
Using SQL Server and ASP.Net, how do I open a recordset and set a variable to equal a field in that recordset. I only have notepad with me right now so it is proving difficult.
Dim NewID as Integer
Recordset = "Select MAX(ID) From myTable"
NewID = Rs.Fields("ID")
is the just of it.
Thanks
-
May 27th, 2004, 07:47 AM
#2
PowerPoster
Ah, you have a lot to learn my brother. Recordsets are of the past. 
Seriously though, do some research on ADO.NET and you'll see your problem can be solved quite easily.
-
May 27th, 2004, 09:27 AM
#3
Frenzied Member
You'll be needing the ExecuteScalar method from the SqlCommand object.
Code:
int NewID;
SqlCommand cmdQuery = new SqlCommand( "Select MAX(ID) From myTable", objConn );
NewID = cmdQuery.ExecuteScalar();
HTH
DJ
-
May 27th, 2004, 11:05 AM
#4
Thread Starter
Hyperactive Member
Thanks
Yes, I do have a lot to learn, I just jumped into this .NET stuff last week, have been focusing on asp/vb6 and finally had time to convert over.
I had thought of using the ExecuteScalar prior to my post, but haven't read up on it so I guess education played me on this one.
Thanks folks.
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
|