怎么在c#里面执行SQL语句使用变量,可以在界面上输入多少,程序显示的就是多少
下面:rows>av的av变量怎么用,我想在程序文本框里面输入的数量就是av的数量.怎么用代码来实现呀?stringconStr="DataSource=127.0.0....
下面: rows > av 的 av变量怎么用,我想在程序文本框里面输入的数量就是av的数量.怎么用代码来实现呀?
string conStr = "Data Source = 127.0.0.1; uid = sa; pwd =Syfjc021; database = WMS";
// int av = 0;
// av = Convert.ToInt32(QTY.Text);
string sqlStr = @"SELECT a.name, b.rows
FROM sysobjects AS a INNER JOIN
sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u') AND (b.indid IN (0, 1)) AND rows > av
ORDER BY b.rows DESC";
SqlConnection sqlCon = new SqlConnection(conStr);
SqlCommand sqlCommand = new SqlCommand(sqlStr, sqlCon);
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = sqlCommand;
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0]; 展开
string conStr = "Data Source = 127.0.0.1; uid = sa; pwd =Syfjc021; database = WMS";
// int av = 0;
// av = Convert.ToInt32(QTY.Text);
string sqlStr = @"SELECT a.name, b.rows
FROM sysobjects AS a INNER JOIN
sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u') AND (b.indid IN (0, 1)) AND rows > av
ORDER BY b.rows DESC";
SqlConnection sqlCon = new SqlConnection(conStr);
SqlCommand sqlCommand = new SqlCommand(sqlStr, sqlCon);
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = sqlCommand;
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0]; 展开
展开全部
这一条语句:string sqlStr = @"SELECT a.name, b.rows
FROM sysobjects AS a INNER JOIN
sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u') AND (b.indid IN (0, 1)) AND rows > av
ORDER BY b.rows DESC";
改为:
string sqlStr = @"SELECT a.name, b.rows
FROM sysobjects AS a INNER JOIN
sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u') AND (b.indid IN (0, 1)) AND rows > " + av +
" ORDER BY b.rows DESC";
这样试一下
FROM sysobjects AS a INNER JOIN
sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u') AND (b.indid IN (0, 1)) AND rows > av
ORDER BY b.rows DESC";
改为:
string sqlStr = @"SELECT a.name, b.rows
FROM sysobjects AS a INNER JOIN
sysindexes AS b ON a.id = b.id
WHERE (a.type = 'u') AND (b.indid IN (0, 1)) AND rows > " + av +
" ORDER BY b.rows DESC";
这样试一下
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询