2
Answers

in data set i have an error


 
Hai,
      I want to display a selected title details in a grid view using data bind method,
using query string i pass the selected title to the grid view page but the error occurs in  dataset like "invalid column name str(ie)selected titlename"
how to solve this error?
public
void bind()
{

string str = Request.QueryString["titlename"];
string connectionstring = @"data source=System-7\sqlExpress;initial catalog=Project;User ID=sa;Password=as;";
SqlConnection con = new SqlConnection(connectionstring);
con.Open();
string query = "select title,suggestion,owner,date from topic1 where title=" + str;
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);//I have an error in this line.
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
Answers (2)