Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
 If dr.HasRows = True Then
                Do While dr.Read
                    facno = dr!facno
                    Call find(facno)//calling sub
                    dr.Close()
                Loop
            End If
public sub find(by val facno as string)
cmd1.CommandText = "select * from maintran where fbankcode='" & "010" & "'" & _
                                           "and facno='" & facno & "'" & _
                                           "and fdate='" & Format(prdate, "yyyy/MM/dd") & "'" & _
                                           "and fbranchcode='" & "01" & "'ORDER BY fvouno"
        With cmd1
            dr1 = .ExecuteReader//error:ExecuteReader: Connection property has not been initialized.
        End With

VB

Posted
Updated 30-Nov-14 21:08pm
v2

Hi,

What is dr1 in Find function? if you have to call the sub function while another datareader is open then in connection string you have to enable MARS(MultipleActiveResultSets).

e.g

C#
string connectionString = "Data Source=MSSQL1;" +
    "Initial Catalog=AdventureWorks;Integrated Security=SSPI;" +
    "MultipleActiveResultSets=True"
 
Share this answer
 
Comments
lakshjoshi 1-Dec-14 3:18am    
i have taken another one reader .
Dim dr1 As SqlClient.SqlDataReader
and i set connection string to MultipleActiveResultSets=True still their is no changes
1.You forgot to set the SqlConnection property of your command object before to execute it.

2.See details in MSDN[^]
 
Share this answer
 
Comments
lakshjoshi 1-Dec-14 3:42am    
thanks works ..
Dim cmd1 As New SqlClient.SqlCommand(facno, cm)..
i didn't connceted right
Raul Iloc 1-Dec-14 9:28am    
Welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900