Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping thru values returned from a database

Status
Not open for further replies.

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"))
 
Open your Visual Studio help and paste this in the address bar:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref4/html/M_System_Data_Common_DataAdapter_Update_1_9a032d43.htm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top