关闭

SQL_添加语句

83人阅读 评论(0) 收藏 举报

 

 SqlConnection con = new SqlConnection("Server=localhost;database=qcwx;uid=sa;pwd=sasasa");

                 con.Open();

                 SqlCommand cmd = new SqlCommand("InsertDate5", con);

                 cmd.CommandType = CommandType.StoredProcedure;

                 cmd.Parameters.Add("@s_name", SqlDbType.VarChar, 50).Value = this.tname.Text;

                 cmd.Parameters.Add("@s_sex", SqlDbType.VarChar, 50).Value = this.RadioButtonList1.SelectedValue;

                 cmd.Parameters.Add("@s_birthday", SqlDbType.VarChar, 50).Value = this.tdate.Text;

                 cmd.Parameters.Add("@s_phone", SqlDbType.VarChar, 50).Value = this.tcell.Text;

                 cmd.Parameters.Add("@s_mobile", SqlDbType.VarChar, 50).Value = this.tphone.Text;

                 cmd.Parameters.Add("@s_email", SqlDbType.VarChar, 50).Value = this.temail.Text;

                 cmd.Parameters.Add("@s_registerDate", SqlDbType.VarChar, 50).Value = this.ttime.Text;

                 cmd.Parameters.Add("@s_password", SqlDbType.VarChar, 16).Value = this.tpass1.Text;

                 cmd.Parameters.Add("@s_logname", SqlDbType.VarChar, 16).Value = this.tname0.Text;

                 try

                  { 

                       cmd.ExecuteNonQuery();

                       MessageBox.Show("用户信息添加成功!");

                  }

                  catch (Exception err)

                  {

                        throw new System.Exception(err.Message);

                   }

                  finally

                   {

                        con.Close();

                   }

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2106次
    • 积分:81
    • 等级:
    • 排名:千里之外
    • 原创:8篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档