C# sql

ggxboy1986 2011-01-21 10:58:01
insert into dbo.MainFrame values ( '"+ dataGridView1.Rows[i].Cells[0].Value.ToString() + "' ,'" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[2].Value.ToString() + "')
上面是一行 我要怎么把它整理成一个 dataGridView1.Rows[i].Cells[0].Value.ToString() 占一行的样式。

就是insert into dbo.MainFrame values ( '"+ dataGridView1.Rows[i].Cells[0].Value.ToString() + "' ,
'" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "',
'" + dataGridView1.Rows[i].Cells[2].Value.ToString() + "')
...全文
58 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
q107770540 2011-01-21
  • 打赏
  • 举报
回复
string sql=string.Format("insert into dbo.MainFrame values ( '{0}','{1}','{2}')", dataGridView1.Rows[i].Cells[0].Value.ToString(),
dataGridView1.Rows[i].Cells[1].Value.ToString(),
dataGridView1.Rows[i].Cells[2].Value.ToString());
笨熊熊 2011-01-21
  • 打赏
  • 举报
回复
string sql = insert into dbo.MainFrame values ( '"+ dataGridView1.Rows[i].Cells[0].Value.ToString() + "' ,";
sql +="'" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "',";
Sql +="'" + dataGridView1.Rows[i].Cells[2].Value.ToString() + "');


or
StringBuilder sb = new StringBuilder();
sb.append(insert into dbo.MainFrame values ( '"+ dataGridView1.Rows[i].Cells[0].Value.ToString() + "' ,";
sb.append(...)

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧