【发布时间】:2014-03-15 12:55:40
【问题描述】:
String start_cd;
String end_cd;
int time_start_int;
int time_end_int;
opencon();
SqlCommand res = new SqlCommand("SELECT ID,Available,Type," + start_cd + "," +
end_cd + " FROM " + going +
" WHERE " + start_cd + "!=0 or " + end_cd + "!=0 and " +
time_start_int + " <= " + start_cd + " <= " + time_end_int + "", con);
SqlDataAdapter sda_res = new SqlDataAdapter(res);
DataTable dt_res = new DataTable();
sda_res.Fill(dt_res);
listBox1.DataSource=dt_res;
listBox1.DisplayMember="ID";
listBox2.DataSource = dt_res;
listBox2.DisplayMember = start_cd;
我想在time_end_int之间获取sql表列值time_start_int
我遇到错误
“
【问题讨论】:
-
不要连接你的字符串,这会让你容易受到 SQL 注入的攻击。
-
转换 int ti 字符串,然后连接字符串。
标签: c# sql sql-server conditional-statements