我刚开始学ASP.NET,自己按照资料敲了一个注册的程序,程序可以运行,但是就是点击"注册"之后不能送到数据库里面,哪位高手帮忙指导一下,小弟感激万分.下面是BUTTON_CLICK的函数,我用的是ACCESS数据库!
private void Button1_Click(object sender, System.EventArgs e)
{
//连接语句
string MyConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath(".")+"..\\db2.mdb;";
string strSel = "select * from Information";
OleDbConnection MyConn = new OleDbConnection(MyConnString);
//参数赋值
OleDbCommand MyComm = new OleDbCommand(strSel,MyConn);
MyComm.CommandType=CommandType.StoredProcedure;
MyComm.Parameters.Add("@ID",TextID.Text);
MyComm.Parameters.Add("@Password",Password1.Value);
MyComm.Parameters.Add("@Name",TextName.Text);
MyComm.Parameters.Add("@Sex",DropDownList1.SelectedItem.Text);
MyComm.Parameters.Add("@Phone",TextPhone.Text);
MyComm.Parameters.Add("@Email",TextEmail.Text);
MyComm.Parameters.Add("@Address",TextAddress.Text);
//存储过程返回值
OleDbParameter paramOut=MyComm.Parameters.Add("@RETURN_VALUE","");
paramOut.Direction=ParameterDirection.ReturnValue;
MyConn.Open();
try
{
MyComm.ExecuteNonQuery();
}
catch{}
finally
{ MyConn.Close();}
}