循环问题帮我 [英] looping problem help me

查看:57
本文介绍了循环问题帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

aryTextFile = Split(RichTextBox2.Text, ",")

olesql = "update table1 set rr_since='" & aryTextFile(i) & "' where rr_code='" & aryTextFile(k) & "'"

Dim olecmd As New OleDb.OleDbCommand
olecmd.CommandText = olesql
olecmd.Connection = oleconn
olecmd.ExecuteNonQuery()
olecmd.Dispose()


请帮助我也循环上面的代码.... tnx.

我希望i=1k=0递增4,每个循环将更新table1,其中rr_code=k.


Please help me too loop the above code....tnx.

I want i=1,k=0 to increment by 4 and every loop it will update the table1 where rr_code=k.

推荐答案

Try:
Try:
For i As Integer = 0 To 3
   olesql = "update table1 set rr_since='" & aryTextFile(i) & "' where rr_code='" & aryTextFile(k) & "'"
   Dim olecmd As New OleDb.OleDbCommand
   olecmd.CommandText = olesql
   olecmd.Connection = oleconn
   olecmd.ExecuteNonQuery()
   olecmd.Dispose()
Next

仅查看使用参数化查询,因为这是对SQL注入攻击的诱因.

Only look at using a Parametrized Query instead, as this is an invitation to an SQL Injection attack.


您也可以这样做

you can also do this

Dim olecmd As OleDb.OleDbCommand
olecmd.Connection = oleconn
For i As Integer = 0 To 3
   olesql = "update table1 set rr_since='" & aryTextFile(i) & "' where rr_code='" & aryTextFile(k) & "'"
   olecmd = New OleDb.OleDbCommand
   olecmd.CommandText = olesql
   olecmd.ExecuteNonQuery()
Next
olecmd.Dispose()


这篇关于循环问题帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆