Hi I am trying a pass a parameter to a query so that when the page loads the information that is loaded is dependant on the passed parameter.
This is the code that is supposed to pass the parameter ID to the SQl query :
If Not Page.IsPostBack Then
If Request.QueryString("Id") Is Nothing Then Response.Redirect("addsections.aspx")
Else
Dim Id As Integer Id = Request.QueryString("Id")
PageIdLabel.Text = Id
SqlSelectCommand1.Parameters.Add("@id", Id)
SqlDataAdapter1.Fill(DataSet11) This is where the error kicks out
This is then the query that is supposed to use the parameter :
SELECT Sections.*
FROM Sections
WHERE (Id =@id)
The Error message I recieve is :
The variable name '@id' has already been declared. Variable names must be unique within a query batch or stored procedure.
I am guessing this is because I have used wrong Syntax somewhere, but i am new to vb.net as well as asp.net and I have to clue whats wrong or whats missing.
Thanks for anyhelp
R Scott
This is the code that is supposed to pass the parameter ID to the SQl query :
If Not Page.IsPostBack Then
If Request.QueryString("Id") Is Nothing Then Response.Redirect("addsections.aspx")
Else
Dim Id As Integer Id = Request.QueryString("Id")
PageIdLabel.Text = Id
SqlSelectCommand1.Parameters.Add("@id", Id)
SqlDataAdapter1.Fill(DataSet11) This is where the error kicks out
This is then the query that is supposed to use the parameter :
SELECT Sections.*
FROM Sections
WHERE (Id =@id)
The Error message I recieve is :
The variable name '@id' has already been declared. Variable names must be unique within a query batch or stored procedure.
I am guessing this is because I have used wrong Syntax somewhere, but i am new to vb.net as well as asp.net and I have to clue whats wrong or whats missing.
Thanks for anyhelp
R Scott