Click here to Skip to main content
15,921,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
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()

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.
Posted
Updated 2-Nov-11 3:04am
v2

Try:
VB
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
Only look at using a Parametrized Query instead, as this is an invitation to an SQL Injection attack.
 
Share this answer
 
you can also do this

VB
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()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900