我正试图利用分化查询显示数据。
try
{
SqlConnection xconn = new SqlConnection();
xconn.ConnectionString = @" Data Source=servername; Database=master; Trusted_Connection=yes ";
xconn.Open();
SqlCommand ycmd = new SqlCommand ("select * from tablename where column1 = @name", xconn);
ycmd.Parameters.Add("@name", dropdownlist.SelectedValue);
SqlDataAdapter da = new SqlDataAdapter(s,xconn);
SqlCommandBuilder cmdbuilder = new SqlCommandBuilder(da);
DataTable dt = new DataTable();
da.Fill(dt);
gridview.DataSource = dt;
gridview.DataBind();
}
catch(Exception ex)
{
label.Text = ex.Message + "
" + ex.StackTrace;
}
我如何工作?