使用下面的代码后,我没有在gridview上获得任何输出,我没有正确连接表
int x = Convert.ToInt32(this.Request.QueryString["outageID"]);
int y = Convert.ToInt32(this.Request.QueryString["toolid"]);
SqlConnection con = new SqlConnection("xyz");//connection name
con.Open();
SqlCommand cmd = new SqlCommand("select * from tblOutageTransactionDetails,tbltools where ToolsOutageID = " + x + "and toolid = " + y, con);
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables;
GridView1.DataBind();
con.Close();
答案 0 :(得分:0)
由于Soner正确地说您的信息有限,但是如果您的查询出现异常,请尝试在and
之前留一个空格,并且一次只从1个表中选择:
SqlCommand cmd = new SqlCommand("select * from tblOutageTransactionDetails where ToolsOutageID = " + x + " and toolid = " + y, con);