D
Damian Franco
Can anyone tell me the best way to do this?
I just want to go through a dataset and as I read I want to run
another store procedure using some of the data from datset1.
I don't know how to do it using dataset and I cant use datareader bec.
only one connection can be open at a time.
Help !!!
example:
Dim order_id as Integer = 1254
Dim myDataReader1 As SqlDataReader
Dim myDataReader2 As SqlDataReader
Dim myConnection As SqlConnection = New SqlConnection...
Dim myCommand1 As SqlCommand = New SqlCommand("s_sp1", myConnection)
myCommand1.CommandType = CommandType.StoredProcedure
myCommand1.Parameters.Add("@Order_id", order_id)
Try
myConnection.Open()
myDataReader1 = myCommand1.ExecuteReader()
While myDataReader1.Read()
....
Cat_Id = myDataReader1("category_id")
Dim myCommand2 As SqlCommand = New SqlCommand("s_sp2",
myConnection)
myCommand2.Parameters.Add("@cat_id", cat_id)
myDataReader2 = myCommand2.ExecuteReader()
if myDataReader2.Read Then
...
end if
myDataReader2.Close
End While
Catch sql_exce As SqlException
....
Finally
myConnection.Close()
myDataReader1.Close
End Try
I just want to go through a dataset and as I read I want to run
another store procedure using some of the data from datset1.
I don't know how to do it using dataset and I cant use datareader bec.
only one connection can be open at a time.
Help !!!
example:
Dim order_id as Integer = 1254
Dim myDataReader1 As SqlDataReader
Dim myDataReader2 As SqlDataReader
Dim myConnection As SqlConnection = New SqlConnection...
Dim myCommand1 As SqlCommand = New SqlCommand("s_sp1", myConnection)
myCommand1.CommandType = CommandType.StoredProcedure
myCommand1.Parameters.Add("@Order_id", order_id)
Try
myConnection.Open()
myDataReader1 = myCommand1.ExecuteReader()
While myDataReader1.Read()
....
Cat_Id = myDataReader1("category_id")
Dim myCommand2 As SqlCommand = New SqlCommand("s_sp2",
myConnection)
myCommand2.Parameters.Add("@cat_id", cat_id)
myDataReader2 = myCommand2.ExecuteReader()
if myDataReader2.Read Then
...
end if
myDataReader2.Close
End While
Catch sql_exce As SqlException
....
Finally
myConnection.Close()
myDataReader1.Close
End Try