文本框中的数据库值,如果选择Combobox ....没有输出gnerating [英] Database values in textbox if select Combobox....no output gnerating
本文介绍了文本框中的数据库值,如果选择Combobox ....没有输出gnerating的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
try
{
con.Open();
string search = "select Amount from Mess_Plans Where PlanName='" + comboBox1_SelectPlan.Text + "' ;";
OleDbCommand cmd1 = new OleDbCommand(search, con);
String i = cmd1.ExecuteReader();
MessageBox.Show("slected" +i);
}
catch(Exception e2)
{
MessageBox.Show(e2.ToString());
}
finally
{
con.Close();
}
推荐答案
应该是:
should be:
comboBox1_SelectPlan.SelectedValue
您应该使用参数化查询来阻止sql注入,请阅读以下内容:
1. 从SQL注入黑客证明你的ASP.NET应用程序 [ ^ ]
2. SQL Injection [ ^ ]
这篇关于文本框中的数据库值,如果选择Combobox ....没有输出gnerating的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文