I'm currently building a VB.net Application and I'm having a problem on reading out records to use in making another record or for computations. For example: table A records will be read and will compute an output to be saved on table B. Tried to use reader on this but i dont seem to get the right syntax. Anyone who could help me out on this? thanks!

well, I am not much sure if this helps...

You cud use ExecuteReader and store the values in some variable and then use those variables to be stored in other table entry..

for eg:

Dim con As SqlConnection
Dim cmd As SqlCommand
Dim query As String = ""
Dim a As String 
Dim b As Integer
Dim dr As SqlDataReader

con = New SqlConnection(". . . . ")
query = ("SELECT * FROM MYTABLE1")
con.open()

cmd = New SqlCommand(query,con)

dr = cmd.ExecuteReader

While dr.Read
   a = GetString(0)
   b = GetInt32(1)
End While

Dim query2 As String = ""
Dim cmd2 As SqlCommand

query2 = "INSERT INTO MYTABLE2 VALUES(' " & a & "','" & B "')"
cmd2 = New SqlCommand(query2,con)

cmd2.ExecuteNonQuery

con.Close()
dr.Close()

well, I am not much sure if this helps...

You cud use ExecuteReader and store the values in some variable and then use those variables to be stored in other table entry..

for eg:

Dim con As SqlConnection
Dim cmd As SqlCommand
Dim query As String = ""
Dim a As String 
Dim b As Integer
Dim dr As SqlDataReader

con = New SqlConnection(". . . . ")
query = ("SELECT * FROM MYTABLE1")
con.open()

cmd = New SqlCommand(query,con)

dr = cmd.ExecuteReader

While dr.Read
   a = GetString(0)
   b = GetInt32(1)
End While

Dim query2 As String = ""
Dim cmd2 As SqlCommand

query2 = "INSERT INTO MYTABLE2 VALUES(' " & a & "','" & B "')"
cmd2 = New SqlCommand(query2,con)

cmd2.ExecuteNonQuery

con.Close()
dr.Close()
This article has been dead for over six months. Start a new discussion instead.