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!

or maybe point me out to an example on the internet.

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()

bornok15,
Can I see your code? Post source code with BB code tags.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.