Database Values

L

leonaisse

Hi

I have been trying to work this out for hours!

I just want to connect to a SQL Server DB and give four session variables
the value of the record returned.

Im just getting to grips with asp.net but in classic asp i would have just
open a recordset and then put......

Session("x") = rs("x")

and so on.....

Whats the best way to code this in asp.net vb? Any snippets would be a
bonus.

Thanks a million

Leonaisse
 
G

Gregory A. Beamer

Hi

I have been trying to work this out for hours!

I just want to connect to a SQL Server DB and give four session
variables the value of the record returned.

Im just getting to grips with asp.net but in classic asp i would have
just open a recordset and then put......

Session("x") = rs("x")

and so on.....

Whats the best way to code this in asp.net vb? Any snippets would be a
bonus.


I can give you links to sites that teach the basics. Here is the flow:

Assume user clicking button and the recordset in question only having
one row of values:

1. user clicks button
2. Button event called
a) Button event calls data retrieve event, which returns a DataSet
3. DataSet values are pulled, like so:

Session("x") = ds.Tables[0].Rows[0]["x"]

I may have the syntax off a bit.

If you want to simplify things, drag the table with the properties on a
DataSet.

1. Add dataset to project and open the designer by clicking on the file
2. Create a database connection in server explorer
3. Drag the table on the DataSet designer

Then add a new query that works by ID.

Then you end up with something like

Dim ds as DataSet = myTableAdapter.MyQuery(id)

The benefit here is setting values goes like this:

Session("x") = ds.MyTable[0].x

which means the x column from row 0 (the first row) in the MyTable
DataTable object.

This is called a strongly typed DataSet (I don't shorten this to STD
personally).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top