Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
for i as Double = 10000001 to 1000099
Dim cmd As New SQLCommand
cmd.CommandText = "Insert Into Xssj (_Identify,编号,产品) Values('" & i & "'100,'PD01')"
cmd.C
cmd.ExecuteNonQuery()
next
for i as Double = 10000001 to 1000099
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Insert Into Xssj (_Identify,编号,产品) Values('" & i & "'100,'PD01')"
cmd.ExecuteNonQuery()
next
for i as Double = 10000001 to 1000099
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Insert Into Xssj (_Identify,编号,产品) Values('" & i & "'100,'PD01')"
cmd.ExecuteNonQuery()
next
for i as Double = 10000001 to 1000099
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Insert Into Xssj (_Identify,编号,产品) Values('" & i & "'100,'PD01')"
cmd.ExecuteNonQuery()
next
for i as Double = 10000001 to 1000099
Dim cmd As New SQLCommand
cmd.CommandText = "Insert Into Xssj (_Identify,编号,产品) Values('" & i & "'100,'PD01')"
cmd.C
cmd.ExecuteNonQuery()
next
代码还能修改一下:
Dim cmd As New SQLCommand
cmd.C
for i as Double = 10000001 to 1000099
cmd.CommandText = "Insert Into Xssj (_Identify,编号,产品) Values('" & i & "'100,'PD01')"
cmd.ExecuteNonQuery()
next
这边能避免在循环中申明变量
Dim cmd As New SQLCommand
cmd. Connectionname = "aaa"
cmd.CommandText = "set IDENTITY_INSERT Xssj ON "
cmd.CommandText &= "Declare @i int "
cmd.CommandText &= "set @i = 10000001 "
cmd.CommandText &= "while @i < 10000100 "
cmd.CommandText &= "begin "
cmd.CommandText &= "Insert Into Xssj (_Identify,编号,产品) Values(@i,100,'PD01') "
cmd.CommandText &= "set @i = @i + 1 "
cmd.CommandText &= "end "
cmd.CommandText &= "set IDENTITY_INSERT Xssj OFF "
cmd.ExecuteNonQuery()
只向数据库提交一次请求,而原来的代码要提交100次请求。
_Identify是自增列也能正常插入