passing a variable from asp to asp.net

  • Thread starter Thread starter Vincent Jones
  • Start date Start date
V

Vincent Jones

in index.asp, i'm passing the this variable:
<a href="Description.aspx?Painting=<%=RS2("Painting")%>">Painting</a>

void Page_Load(Object sender, EventArgs e)
{
SqlConnection myConnection = new
SqlConnection("server=111.111.111.111;uid=;pwd=;database=mdMuseumStore");
SqlDataAdapter myCommand = new SqlDataAdapter("Select Painting,
Artist, Title, Description from tbManetPaintings Where Painting =
'"Request.QueryString["Painting"]"'", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "tbManetPaintings");
MyRepeater.DataSource =
ds.Tables["tbManetPaintings"].DefaultView;
MyRepeater.DataBind();
}

I always get
CS1026: ) expected
 
You have a simple concatenation error...
Make a very small change.
------------------------
SqlDataAdapter myCommand = new SqlDataAdapter("Select Painting,"
+ " Artist, Title, Description from tbManetPaintings Where Painting = '"
+ Request.QueryString["Painting"] + "'", myConnection);
------------------------
or, even better, use a command and parameter (easier to read, safer)
------------------------
SqlCommand cmd = new SqlCommand("Select Painting,"
+ " Artist, Title, Description from tbManetPaintings Where Painting =
@Painting", myConnection);
cmd.Parameters.Add("@Painting",Request.QueryString["Painting"]);
SqlDataAdapter myCommand = new SqlDataAdapter(cmd);
 
Try thi

SqlConnection myConnection = new SqlConnection("server=111.111.111.111;uid=;pwd=;database=mdMuseumStore")
HttpRequest hr = new HttpRequest("1", "2", "3")
SqlDataAdapter myCommand = new SqlDataAdapter
"Select Painting, Artist, Title, Description from tbManetPaintings Where Painting ='" + hr.QueryString["Painting"] + "'", myConnection)
DataSet ds = new DataSet()
myCommand.Fill(ds, "tbManetPaintings")
MyRepeater.DataSource = ds.Tables["tbManetPaintings"].DefaultView
MyRepeater.DataBind();
 
Back
Top