在C#中,如何处理批数据读取或插入,数据库是sql的 我是一个新手,不知道怎么样处理批量数据,在网上找了很久,基本上都是vb的或是c++的,要不数据库就是oracle的,哪位大侠知道怎么处理C#程序的吗?指点一下 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 insert into a select * from b 例如protected void Button1_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source=172.16.50.111;Initial Catalog=sa;Persist Security Info=True;User ID=sa;Password=webadmin;Pooling=False"; try { conn.Open(); string sql = "Insert into Table2(ID,Name,Sex,Age) values('" + TextBox1.Text + "', '" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "')"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.ExecuteNonQuery(); } catch (Exception expt) { throw new ApplicationException(expt.Message); } finally { conn.Close(); } } 如果是程序里的数据批量插入数据库,则在cs代码里面for如果是数据库里面的数据批量,则在存储过程里面循环 insert into 表名 select 列名,列名 union select 列名,列名 union select 列名,列名 将数据定义为XML格式,将起传入数据库,在数据库中用XPATH解析这个XML存入! 關於使用rsa 電子簽名加解密問題 winform打包后实行安装的程序说找不到xml文件,怎么解决啊? 高分,急,有关C# c/s模式的 VS2008的“添加扩展程序”怎么不见了? 简单问题,如何实现"请稍候"的功能. 菜鸟求助,组件的问题 自己制作的浏览器如何打开新页面? 如何从Windows服务中传回数据? DevExpress xpo 的dataobject 用什么工具生产的? VC_User_CRT71_RTL_X86-.msm和VC_User_MFC71_RTL_X86-.msm winfrom怎么制作多列的ListBox? 统计在线情况的问题
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=172.16.50.111;Initial Catalog=sa;Persist Security Info=True;User ID=sa;Password=webadmin;Pooling=False";
try
{
conn.Open();
string sql = "Insert into Table2(ID,Name,Sex,Age) values('" + TextBox1.Text + "', '" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "')";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
}
catch (Exception expt)
{
throw new ApplicationException(expt.Message);
}
finally
{
conn.Close();
}
}
如果是数据库里面的数据批量,则在存储过程里面循环