PC Review


Reply
Thread Tools Rate Thread

Database Values

 
 
leonaisse
Guest
Posts: n/a
 
      17th Jul 2009
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


 
Reply With Quote
 
 
 
 
Gregory A. Beamer
Guest
Posts: n/a
 
      17th Jul 2009
"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! |
*******************************************
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
score object property values against a decision rule created from from database table record values? hazz Microsoft VB .NET 3 3rd Jul 2005 06:52 PM
How to Add an All Values Item to a Database Query by Using the FrontPage 2003 Database Results Wizard =?Utf-8?B?RGFuaWVs?= Microsoft Frontpage 4 2nd Feb 2004 05:36 PM
Database values.... atif Microsoft ASP .NET 0 16th Jan 2004 10:18 AM
FP and SQL Database values Art Microsoft Frontpage 6 20th Nov 2003 10:45 PM
Re: Adding custom values and database values to DropDwonList William F. Robertson, Jr. Microsoft ASP .NET 0 1st Jul 2003 07:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:02 PM.