日期:2014-05-17  浏览次数:20853 次

高手帮看看,
  private void Form2_Load(object sender, EventArgs e)
        {
            label1.Text = clakk.claname.SendNameValue.ToString();
            con.Open();//打开数据库连接
            string sql = "select * from xsxb where stid= '"+clakk.claname.SendNameValue.ToString()+"'";
            SqlDataReader pdr = G_SqlExecute.GetReader(sql);
            pdr.Read();
            if (pdr.HasRows)
            {
                string bstid = pdr["stid"].ToString();
                string bxm = pdr["xm"].ToString();
                string bxb = pdr["xb"].ToString();
                string bbj = pdr["bj"].ToString();
                string bsex = pdr["sex"].ToString();
                using (SqlCommand command = new SqlCommand("INSERT INTO stute VALUES (@stid,@xm,@xb,@bj,@sex,@sj)", con))
                {
                    command.Parameters.Add("@stid",//添加参数并赋值
                        SqlDbType.VarChar, 20, "stid").Value = bstid;

                    command.Parameters.Add("@xm",//添加参数并赋值
                        SqlDbType.VarChar, 50, "xm").Value = bxm;
                    command.Parameters.Add("@xb",//添加参数并赋值
                        SqlDbType.VarChar, 30, "xb").Value = bxb;
                    command.Parameters.Add("@bj",//添加参数并赋值
                        SqlDbType.VarChar, 30, "bj").Value = bbj;
                    command.Parameters.Add("@sex",//添加参数并赋值
                       SqlDbType.VarChar