c# 数据库 插入功能 insert 语句 values怎么填
|
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 应该怎么填 |
免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。
版权声明:作者保留权利,不代表本站立场。
|
|
|
|
|
|
|
|
insertintoxsdata(Sxh,Sxm,Sxb,Scsrq,Szy,Sdk,Ssfzh,Sjg,Sjtdz)values(value1,value2...)值对应就行了 |
|
|
|
|
|
|
|