how do i reference one of the DB columns found within a dataset?

  • Thread starter Thread starter omar
  • Start date Start date
O

omar

i have this code (below) it finds a record based on username and password
column entered in textboxes.

Now my question is how do i reference just one of the DB columns found
within the dataset [Not to bind to a server control, but to set its value to
a session?] Once the record is found, I want to set the value of the user_id
column to a session.
In ASP it would simply be: Recordset("column_name") ... but how is it in
asp.net

<script runat="server">
sub btnlogin(s as object, e as eventargs)
dim dsetgetuser as dataset
dim conngetuser as oledbconnection
dim dadpgetuser as oledbdataadapter
dim dvwgetuser as dataview
dim arrvalues(1) as object
dim introwindex as integer

' dim dtblgetuser as datatable
' dim dcolgetuser as datacolumn

dsetgetuser = new dataset()

'create connection
conngetuser = new oledbconnection("provider=microsoft.jet.oledb.4.0;data
source=c:/documents and settings/administrator/desktop/aspnet/db.mdb")

dadpgetuser = new oledbdataadapter("SELECT user_id, username,

userpwd FROM tblusers", conngetuser)
dadpgetuser.fill(dsetgetuser, "tblusers")

'create dataview
dvwgetuser = dsetgetuser.tables("tblusers").defaultview()
dvwgetuser.sort ="username, userpwd"

'find username and password
arrvalues(0) = txtusername.text
arrvalues(1) = txtuserpwd.text
introwindex = dvwgetuser.find(arrvalues)

' dtblgetuser = dsetgetuser.tables("tblusers")
' dcolgetuser = dtblgetuser.columns("user_id")
' dcolgetuser.defaultvalue = 1

' check if record is found
if introwindex <> -1 then
response.write("found")
else
response.write("NOT found")
end if

end sub
</script>
 
Omar,

Will the resulting table have only one record? If so

dsetgetuser.tables("tblusers").Rows(0)("user_id") = <session id>

Kathleen
 
Back
Top