以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 直接大量写入后台数据的疑问 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=162211) |
-- 作者:yellow -- 发布时间:2021/4/9 0:41:00 -- 直接大量写入后台数据的疑问 需要向数据表大量写入数据,所以采用了后台直接写入。是这样把SQLCommand语句放到循环体内执行吗?是不是有点不妥啊? For i As Integer = 0 To ja.count - 1 Dim ja1 As JArray = ja(i) \'直接写入后台数据 Dim cmd As new SQLCommand cmd. Connection Name = "KEDAO" cmd.CommandText = "Insert Into TBdaily (" & dcol & ") Values(" & cs & ")" cmd.Parameters.Add("@name",ja1(0).ToString) cmd.Parameters.Add("@date",ja1(1).ToString) cmd.Parameters.Add("@om",ja1(2).ToString) cmd.Parameters.Add("@high",ja1(3).ToString) cmd.Parameters.Add("@low",ja1(4).ToString) cmd.Parameters.Add("@end",ja1(5).ToString) cmd.Parameters.Add("@pre",ja1(6).ToString) cmd.Parameters.Add("@change",ja1(7).ToString) cmd.Parameters.Add("@chg",ja1(8).ToString) cmd.Parameters.Add("@vol",ja1(9).ToString) cmd.Parameters.Add("@amount",ja1(10).ToString) cmd.ExecuteNonQuery Else [此贴子已经被作者于2021/4/9 0:43:36编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/4/9 8:41:00 -- Dim cmd As new SQLCommand cmd. Connection Name = "KEDAO" cmd.CommandText = "Insert Into TBdaily (" & dcol & ") Values(" & cs & ")" For i As Integer = 0 To ja.count - 1 Dim ja1 As JArray = ja(i) \'直接写入后台数据 cmd.Parameters.clear cmd.Parameters.Add("@name",ja1(0).ToString) cmd.Parameters.Add("@date",ja1(1).ToString) cmd.Parameters.Add("@om",ja1(2).ToString) cmd.Parameters.Add("@high",ja1(3).ToString) cmd.Parameters.Add("@low",ja1(4).ToString) cmd.Parameters.Add("@end",ja1(5).ToString) cmd.Parameters.Add("@pre",ja1(6).ToString) cmd.Parameters.Add("@change",ja1(7).ToString) cmd.Parameters.Add("@chg",ja1(8).ToString) cmd.Parameters.Add("@vol",ja1(9).ToString) cmd.Parameters.Add("@amount",ja1(10).ToString) cmd.ExecuteNonQuery Else 如果是sqlserver,建议看看:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=147288&replyID=60077&skin=1 或者:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=159738&replyID=&skin=1 |