"leonaisse" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):
> 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).
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Twitter: @gbworld
Blog:
http://gregorybeamer.spaces.live.com
*******************************************
| Think outside the box! |
*******************************************