"select * from lcy_register where user=" + textBox1.Text;
解决方案 »
- 前台显示不同尺寸的缩略图
- 有关IE中直接打开word、excel、pdf等文档(是直接打开不需要下载提示,也不需要客户端修改IE安全设置)
- 推荐个 软件下载类型 的 网站 学习使用
- 怪事:一个类中居然有同名的方法和字段!
- 线程问题,带参数,启动的线程的个数!
- 异常详细信息: System.InvalidOperationException: ExecuteReader: Connection 属性尚未初始化。寻求高手帮忙,急!!!!!
- 不懂就问吧..我得到了一个System.Reflection.Assembly assembly对象
- 关于分页的问题
- 请问VSS2005中,怎样让某几个项目能让某个人访问,某几个不能?
- 绝对难度,绝对挑战,绝对挑战。关于如何控制线程的个数?先送100分,可以在加
- tooltip如何不行了?
- 有关DataGrid的问题
这句话好象也有错吧。。string sele1="select * from lcy_register where user=" + textBox1.Text;
int row1=sqlSelectCommand1.ExecuteNonQuery();
改为。this.DataAdapterUserLogin.SelectCommand1.ExecuteScalar() == null
来判断。。
改为:
string sele1="select * from lcy_register where user="+textBox1.Text;2.int row1=sqlSelectCommand1.ExecuteNonQuery();
改为:
int row1=sqlSelectCommand1.ExecuteScalar();
string sele1="select * from lcy_register where user="+textBox1.Text.Trim();
sqlConnection1.Open();
sqlSelectCommand1=new SqlCommand(sele1,sqlConnection1);
if(sqlSelectCommand1.ExecuteScalar() == null)
{
MessageBox.Show("没有该用户,请先进行注册,再使用本系统!");
}
else
{
sele1="select * from lcy_register where user="+textBox1.Text.Trim()+" and password="+textBox2.Text.Trim();
sqlSelectCommand1=new SqlCommand(sele1,sqlConnection1);
if(sqlSelectCommand1.ExecuteScalar() == null)
{
MessageBox.Show("输入的密码不正确,请重新输入密码!");
}
else
{
Form1 f2=new Form1();
f2.Show();
}
}
当我输入正确的用户名和密码时,仍会出现在"输入的密码不正确,请重新输入密码!",另使用
int row1=sqlSelectCommand1.ExecuteScalar();或int row1=Convert.toint32(sqlSelectCommand1.ExecuteScaler())都会出现错误
改为
string sele1="select * from lcy_register where user = "'" + textBox1.Text.Trim()+"'";
int row1=sqlSelectCommand1.ExecuteNonQuery();这句话当然有问题,在执行select语句的时候,返回的是记录集,而不是受影响的记录数,ExecuteNonQuery这个方法只能对Update、Insert、Delete才起作用。因此你需要借用其它工具如SqlDataReader。
string strQuery="select * from lcy_register where [user]="+textBox1.Text.Trim();
string strQuery="select * from lcy_register where [user]='"
+textBox1.Text.Trim()+"'";
会出现未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中其他信息:系统错误。后面的程序段根本无法执行,请问为什么
try
{
sqlSelectCommand1=new sqlCommand(sele1,sqlConnection1);
}
catch(SqlException err)
{
MessageBox.Show(err.Message);
}看看会显示什么错误?
try
{
sqlSelectCommand1=new sqlCommand(sele1,sqlConnection1);
}
catch(SqlException err)
{
MessageBox.Show(err.Message);
}看看会显示什么错误?
把 sqlSelectCommand1=new sqlCommand(sele1,sqlConnection1);
改成如下试一试:
System.Data.SqlClient.SqlCommand sqlSelectCommand1 =
new System.Data.SqlClient.SqlCommand (sele1,sqlConnection1);------------------------------------------------------------------
还有SQL语句应该象Knight94(愚翁) 所说,如果是非数字类型的字符则必须加单引号(不能是双引号哈),但如果是数字类型的字符,如:'1'与数字1 在SQL Server中是可以帮你纠正的。