日期:2014-05-18 浏览次数:20687 次
SqlConnection thisConn = new SqlConnection("server=.;uid=sa;pwd=;database=x6"); thisConn.Open(); string MySql = "insert into student (name,age,sex,score) values (@name,@age,@sex,@score)"; SqlCommand thisComm = new SqlCommand(MySql, thisConn); SqlParameter name = new SqlParameter("@name", SqlDbType.Char, 50); SqlParameter age = new SqlParameter("@age", SqlDbType.Int, 50); SqlParameter sex = new SqlParameter("@sex", SqlDbType.Char, 50); SqlParameter score = new SqlParameter("@score", SqlDbType.Int, 50); thisComm.Parameters.Add(name); thisComm.Parameters.Add(age); thisComm.Parameters.Add(sex); thisComm.Parameters.Add(score); name.Value = "西毒"; age.Value = "40"; sex.Value = "男"; score.Value = "88"; thisComm.ExecuteNonQuery(); thisConn.Close();