Nsan
MIS
- Apr 30, 2003
- 13
Looping thru values returned from a database and passing the values to a method.
I need to retrieve names(5000) from a database and modify each value by passing it to a function then that returned value needs to be updated in the database. So far no luck.
Dim ConnString As String = "Server=(local);Database=northwind;Integrated Security=true"
con As New SqlConnection(ConnString)
con.open()
Dim da As New SqlDataAdapter("select name from contact", con)
Dim ds As New DataSet()
da.Fill(ds, "contact")
For Each row As DataRow In ds.Tables ("contact").Rows
row("name") = functioncall(row("name"))
Next
New SqlCommandBuilder(da)
da.Update(ds.Tables("contact"))
I need to retrieve names(5000) from a database and modify each value by passing it to a function then that returned value needs to be updated in the database. So far no luck.
Dim ConnString As String = "Server=(local);Database=northwind;Integrated Security=true"
con As New SqlConnection(ConnString)
con.open()
Dim da As New SqlDataAdapter("select name from contact", con)
Dim ds As New DataSet()
da.Fill(ds, "contact")
For Each row As DataRow In ds.Tables ("contact").Rows
row("name") = functioncall(row("name"))
Next
New SqlCommandBuilder(da)
da.Update(ds.Tables("contact"))