为了账号安全,请及时绑定邮箱和手机立即绑定

c# 数据库 插入功能 insert 语句 values怎么填

c# 数据库 插入功能 insert 语句 values怎么填

C#
慕妹4321516 2017-12-08 20:37:17
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; namespace WebApplication1 {     public partial class CmdDataReadInsert : System.Web.UI.Page     {         private String Strconnection;         private String str;         private SqlConnection conn;         private SqlCommand cmd;         private SqlDataAdapter da;         protected void Page_Load(object sender, EventArgs e)         {             Strconnection= "Data Source =.; Initial Catalog = student; Integrated Security = True";             conn = new SqlConnection(Strconnection);             str = "select * from xsdata";             da = new SqlDataAdapter(str,conn);             SqlCommandBuilder cb = new SqlCommandBuilder();         }         protected void Button1_Click(object sender, EventArgs e)         {             try             {                 conn.Open();                 string sqltable = string.Format("select * from xsdata");                 string insertstu = string.Format("insert into xsdata(Sxh,Sxm,Sxb,Scsrq,Szy,Sdk,Ssfzh,Sjg,Sjtdz)values ");                 SqlDataAdapter da = new SqlDataAdapter(sqltable,conn);                 DataSet ds = new DataSet();                 da.Fill(ds);                 DataRow dr = ds.Tables[0].NewRow();                 dr["Sxh"] = this.Sxh.Text;                 dr["Sxm"] = this.Sxm.Text;                 dr["Sxb"] = this.Sxb.SelectedValue.ToString();                 dr["Scsrq"] = Convert.ToDateTime(this.Scsrq.Text);                 dr["Szy"] = this.Szy.SelectedValue.ToString();                 dr["Sdk"] = this.Sdk.SelectedValue.ToString();                 dr["Ssfzh"] = this.Ssfzh.Text;                 dr["Sjg"] = this.Sjg.Text;                 dr["Sjtdz"] = this.Sjtdz.Text;                 ds.Tables[0].Rows.Add(dr);                 da.InsertCommand = new SqlCommand(insertstu, conn);                 da.Update(ds);                 conn.Close();             }             catch (SqlException se)             {                 Response.Write(se.Message.ToString());             }                         }     } }c# 连接数据库做插入功能  insert 语句的 values 应该怎么填
查看完整描述

1 回答

?
堂堂堂堂糖糖糖童鞋

TA贡献101条经验 获得超58个赞

insert into xsdata (Sxh,Sxm,Sxb,Scsrq,Szy,Sdk,Ssfzh,Sjg,Sjtdz) values (value1, value2...)

值对应就行了

查看完整回答
反对 回复 2017-12-10
  • 1 回答
  • 0 关注
  • 2182 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信