关于执行 SqlCommand com = new SqlCommand(sql,con);的问题
[
这个是我写的代码,问过很同学。他们都说语法没有错误,可是就是读不出数据库里面的数据。Convert.ToInt32(cmd.ExecuteScalar()) 的结果是零
SqlConnection con = new SqlConnection("server=AIXUE-PC\\WUSHENGQI;database=sushe;uid=sa;pwd=1234");
con.Open();
string slt = "select count(*) from name_Table where Password=@password and User=@user";
SqlCommand cmd = new SqlCommand(slt, con);
cmd.Parameters.Add(new SqlParameter("@user",SqlDbType.Char,20));
cmd.Parameters["@user"].Value = TextBox1.Text;
cmd.Parameters.Add(new SqlParameter("@password", SqlDbType.Char, 20));
cmd.Parameters["@password"].Value = TextBox2.Text;
if (Convert.ToInt32(cmd.ExecuteScalar()) >0)
{
Response.Redirect("../manage/manage.aspx");
}
else
{
ClientScript.RegisterStartupScript(GetType(), "提示", "<script>alert('用户名或密码错误')</script>");
}这个是我写的代码,问过很同学。他们都说语法没有错误,可是就是读不出数据库里面的数据。Convert.ToInt32(cmd.ExecuteScalar()) 的结果是零
...全文
相关推荐
在.net下使用sql2000 image类型数据
;database=bdqn;uid=sa;pwd=sa;")){ con.Open(); // 创建SqlCommand对象 SqlCommand com = con.CreateCommand();
C# SQL Server 2000备份还原代码
```csharp SqlCommand cmd = new SqlCommand(sqlstr, con); cmd.Connection = con; num = cmd.ExecuteNonQuery
SQL Server存储过程调用方法的研究.pdf
"])) { SqlCommand m_Com = new SqlCommand(m_SqlString, m_Con); m_Con.Open(); // 执行数据库读取操作 SqlDataReader
判断用户注册用户时用户名是否重名
- 示例:`SqlCommand com = new SqlCommand("insert into admin values(@uname, @pwd)", hyqpm.con);` - 设置参数值:
图片保存到数据库的方法.doc
imageb.Length); fs.Close(); // 创建SqlCommand对象并设置SQL语句 SqlCommand com3 = new SqlCommand(sql, con); //


