![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
OleDB
This is really ASP.NET, but I'm using VB as the language, so I thought i'd post it here for lack of a better place.
anyway, i have this code: Dim objConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DBPath))
Try
objConn.Open()
Catch ex As OleDbException
Response.Write("<script>alert('Could not connect to the database.\nPlease contact the administrator.');</script>")
Exit Sub
End Try
Dim objCmd As New OleDbCommand("SELECT post FROM teacher_info WHERE username='" & Session.Item("Username") & "'", objConn)
'ERROR LINE JUST BELOW
Dim objDataReader As OleDbDataReader = objCmd.ExecuteReader
'ERROR LINE JUST ABOVE
objDataReader.Read()
txtBulliten.Text = objDataReader.Item("post")and when i try to run it the line i marked as error line throws a oledbexception. anybody have any idea what's wrong? thanks.
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
#2 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
What is the exception message?
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#3 | |
|
Hobbyist Programmer
|
the exception message:
Quote:
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Take a look at the MSDN page - you have to implement it in a specific way.
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
um, is there something im missing between the example and what i have?
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Sorry - I thought there was, but it seems your code should be fine, semantically at least. What exactly is the error message?
|
|
|
|
|
|
#7 |
|
Hobbyist Programmer
|
hmm, it looks good to me, I know this may sound stupid but try putting a () on the end
like in the example on MSDN: myReader = myCommand.ExecuteReader() I've seen dumber things happen before in .NET, it should automatically put it in there, I assume you copy/pasted this, it should be in there. I've actually had errors as a result of this before, give it a try. so try changing this: Dim objDataReader As OleDbDataReader = objCmd.ExecuteReader to this: Dim objDataReader As OleDbDataReader = objCmd.ExecuteReader() lemme know if this makes a difference, I'm curious
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|