c#insert into
通过insert into 将控件textbox1,textbox2,textbox..... 插入到SQL server表cloud中。然后绑定到数据库,在dataGridView中显示出来. --------------------编程问答-------------------- SqlConnection myConnection = new SqlConnection(sqlconn);
myConnection.Open();
SqlCommand myCommand = new SqlCommand("insert ...", myConnection);
myCommand.ExecuteNonQuery();
SqlConnection conn = new SqlConnection(connstr);
SqlDataAdapter adapter = new SqlDataAdapter(str, conn);
DataSet myset = new DataSet();
adapter.Fill(myset, "表");
datagridview1.DataSource = myset.Tables["表"].DefaultView;
datagridview1.DataBind();
--------------------编程问答-------------------- 梦大,能吧insert 写纤细点吗?
--------------------编程问答--------------------
--------------------编程问答--------------------
string sql="INSERT INTO 表名(字段名1,字段名2) VALUES('" & this.TextBox1.Text & "','" &this.TextBox2.Text & "')"
楼上即是。。。 --------------------编程问答-------------------- SqlConnection myConnection = new SqlConnection(sqlconn);
myConnection.Open();
SqlCommand myCommand = new SqlCommand("insert ...", myConnection);
myCommand.ExecuteNonQuery();
SqlConnection conn = new SqlConnection(connstr);
SqlDataAdapter adapter = new SqlDataAdapter(str, conn);
DataSet myset = new DataSet();
adapter.Fill(myset, "表");
datagridview1.DataSource = myset.Tables["表"].DefaultView;
datagridview1.DataBind(); --------------------编程问答-------------------- 1、不清楚楼主想问什么? 普通的ADO.Net?还是自动处理界面控件与数据库的关联?
2、普通ADO.Net,去百度一下。
sql = string.Format("Insert Into T(f1,f2) Values('{0}','{1}')",txtBox1.Text,TxtBox2.Text);
3、自动处理:对TextBox命名方法进行规范化,如Txt_数据库字段名
4、至于绑定,楼上的OK
有人回复了我的帖子,竟然没发现。用《Csdn收音机》告别烦恼!
补充:.NET技术 , C#