Last post Sep 11, 2005 05:12 PM by capola
Sep 11, 2005 05:12 PM|capola|LINK
I am quite new to ASP.net and I am trying something I cannot find the appropriate info on. I basically want to run a "select"query at page load, the query returns one result, and I want to redirect to another page and pass that result as querystring parameter.
The problem is I cannot figure out how to run the query. I looked in different places and couldn't find much info. So I look at asp.net 1.1 and I found one example which uses the OledbConnection object. I tried to use it however I get an error, and I am not
sure how to fix it.
Here is my code:
Dim UserID As String = Request.QueryString("id")
If UserID <> "" Then
Dim connectionObject as new oledb.OleDbConnection(configurationmanager.AppSettings("MyDB"))
Dim commandObject As New OleDb.OleDbCommand("select URL from User where UserID=" +UserID, connectionObject)
Dim readerObject as OleDb.OleDbDataReader
readerObject = commandObject.ExecuteReader
Catch exp As Exception
Based on the debugging I did there is something wrong with the connection string. What
I have in my web.config is:
<add name="MyDB" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\mydb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>