连接数据库出错
string str = "Data Source=192.168.0.31;Initial Catalog=13141516;Persist Security Info=True;User ID=sa;Password=1";string sr = "select * from QqjyTbMasters where='" + this.DropDownList1.Text+ "'";
SqlConnection scn = new SqlConnection(str);
try
{
scn.Open();
SqlDataAdapter sda = new SqlDataAdapter(sr, scn);
DataSet ds =new DataSet();
sda.Fill(ds, "QqjyTbMasters");
if (ds.Tables["QqjyTbMasters"].Rows.Count > 0)
{
GridView1.DataSource = ds.Tables["QqjyTbMasters"].DefaultView;
GridView1.DataBind();
}
else
{
Response.Write("没有相关资料");
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
scn.Close();
}
第 1 行: '=' 附近有语法错误。