呵呵,那就不好意思,比较笨的方法拉,在存储过程里头放两个参数,一个输入,一个输出,好像也可以用SqlDataAdapter做,还比较好点啦
protected void Button2_Click(object sender, EventArgs e)
{
string username;
username = TextBox1.Text;
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=vote;User ID=sa;Password=sa");
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "vote";
string opt = RadioButtonList1.SelectedValue;
com.Parameters.Add("username", SqlDbType.NVarChar);
com.Parameters["username"].Direction = ParameterDirection.Input;
com.Parameters["username"].Value = username;
com.Parameters.Add("opt", SqlDbType.NVarChar);
com.Parameters["opt"].Direction = ParameterDirection.Input;
com.Parameters["opt"].Value = opt;
int result=1;
com.Parameters.Add("result", SqlDbType.Int);
com.Parameters["result"].Direction = ParameterDirection.Output;
com.Parameters["result"].Value = result;
com.ExecuteNonQuery();
int i;
i = Convert.ToInt32(com.Parameters["result"].Value);
if (i == 1)
{
Button3.Enabled = true;
}
else
{
Response.Write("对不起,请你注册!");
}
con.Close();
}
有比较简单的方法的话,那就传上来看看咯
不过我觉得vb还其他的语言简单点嘞