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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querystring in Codebehind

Status
Not open for further replies.

Ecreations

Programmer
Jul 6, 2002
220
CA
I am building a small web application in VS.Net 2003
the application uses an access database the SQL statement goes like this
"Select field1,field2,field3 from table where field1="&IntID
IntID is variable declared and its value assigned to it from a Querystring
When i test it i dont get any records but if i change IntID with Request.Querystring("ID") in the sql statement everything works ok.

any idea where the variable IntID should be declared and if it has to be declared as a public variable in the class.
I have moved the variable declaration in many places but still the result is the same.
I did not import any name spaces, i just left it with VS.NET default name spaces and imports

Thanks in advance
 
figured it out
just needed to run the sql statement in the page load sub and open the database from there
it even gave better performance

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        MYID = Request.QueryString("ID")
        If Not IsPostBack Then
            Me.OleDbSelectCommand1.CommandText = "SELECT Field1, Field2, Field3," & _
                    " KeyField FROM MyTable where Field1="&MyID
            Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
            Me.OleDbDataAdapter1.Fill(Me.DsQuestions)
            DRQuestions.DataBind()
'test Querystring value
            'Response.Write("The ID is " & MYID)
        End If

    End Sub


The solution is simple, the problem is complex.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top