Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hello, as can be seen below, i'm t 1

Status
Not open for further replies.

mattbold

Programmer
Oct 5, 2001
45
GB
hello,
as can be seen below, i'm trying to get the value of a field from my database and assign it to a session variable, but i just get this error:
"System.InvalidOperationException: No data exists for the row/column."

i'm new to asp.net so apologise if this is a fairly weak problem but it's been getting at me all day! if anyone could help out that would be grand...

my code at the moment:

Dim conn As OleDbConnection
Dim cmd As OleDbCommand
Dim result As String
Dim dbread As OleDbDataReader

conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("project.mdb"))

Dim strSQL2 As String = "select * from tblBasicUser where Username = '" & txtUsername.Text & "' and Password = '" & txtPassword.Text & "'"

conn.Open()
cmd = New OleDbCommand(strSQL2, conn)

dbread = cmd.ExecuteReader()
Session("userid") = dbread.Item(1)


cheers,
matt
 
Hey matt,

well, since its saying that there's no data in that row/column, are you sure that the query you're executing is actually returning anything?

if it is, then the other thing I'd suggest is checkign to see (I've never used a reader so I'm not 100% on this, but...) if the Item property of a reader has a cell property as well. It could be that you're trying to access the entire row itself rather than the cell holding the data.
i.e.
dbread.Item(1).Cell(0)

Again, not 100% sure, but something to check out anyway.

D'Arcy
 
dbread = cmd.ExecuteReader()
dbread.read()
Session("userid") = dbread.Item(1) Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top