各位ASP.NET和ADO.NET的高手们请进

来源:百度知道 编辑:UC知道 时间:2024/05/16 07:18:39
我写了个用户登陆的一个程序。可是由于本人新手不懂,需要大虾们帮我看一下这个该如何做修改。
private void But_dl_Click(object sender, System.EventArgs e)
{
string name = this.txt_name.Text;
string pwd = this.txt_pwd.Text;
SqlConnection conn = new SqlConnection();
conn.ConnectionString ="initial catalog=dl;data source='.';integrated security =true";
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection= conn;
cmd.CommandText="select user_name,user_pwd from user_dl where user_name=@user_name and user_pwd=@user_pwd";
cmd.CommandType= cmd.CommandText;
SqlParameter UName = new SqlParameter();
UName.ParameterName="@user_name";
UName.SqlDbType = SqlDbType.Char;
UName.Value= this.txt_name.Text;
SqlParameter UPwd = new SqlParameter();
UPwd.ParameterName="@user_pwd";
UPwd.SqlDbType = SqlDbType.Char;
UPwd.Value= this.txt_pwd.Text;
cmd.Parameters.Add(UName);
cmd.Para

cmd.CommandType = CommandType.Text

这个存储过程中有问题:
SqlCommand cmd = new SqlCommand();
cmd.CommandText="dbo.pro_Locad";
cmd.CommandType=CommandType.StoredProcedure;
cmd.Connection=join;
SqlParameter ParIn =cmd.Parameters.Add("@uid",SqlDbType.VarChar,10);
ParIn.Direction=ParameterDirection.Input;
ParIn.Value=this.textBox1.Text;

SqlParameter ParIn2 =cmd.Parameters.Add("@upass",SqlDbType.VarChar,10);
ParIn2.Direction=ParameterDirection.Input;
ParIn2.Value=this.textBox2.Text;

SqlParameter ParOut =cmd.Parameters.Add("@usort",SqlDbType.VarChar,10);
ParOut.Direction=ParameterDirection.Output;

这是我做的。
1、你少这个参数是输入还是输出
2、画蛇添足。cmd.CommandText="select user_name,user_pwd from user_dl where ……是可省的

发生了什么错误啊
贴出来啊

cmd.CommandType= cmd.CommandText; 去掉~~