Here's what I have:
VB Code:
Public Function UseSQLDBExecuteReader() As SqlDataReader Dim lRead As SqlDataReader If mSQLDBCmd Is Nothing Then Throw New Exception("Must use SetSQLDBCommand to initialize SQLCommand object!") Exit Function End If If mSQLDBConnector Is Nothing Then mSQLDBConnector = New SqlConnection(mSQLDBConnString) mSQLDBConnector.Open() else If Not IsSQLDBOpen() then mSQLDBConnector.Open() end if End If Try With mSQLDBCmd .Connection = mSQLDBConnector lRead = mSQLDBCmd.ExecuteReader(CommandBehavior.CloseConnection) End With Catch ex As Exception Throw New Exception(ex.ToString()) Finally mSQLDBCmd.Dispose() mSQLDBCmd = Nothing ' mSQLDBConnector.Close() ' mSQLDBConnector = Nothing End Try Return lRead End Function
And the calling code:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim db As New Database.SQLDatabase("User ID=QuikFix;Password=ibm123;Initial Catalog=QuikFix;Data Source=HERCULES;") Dim dr As SqlDataReader Dim da As SqlDataAdapter Dim ds As DataSet db.SetSQLDBCommand("select_ticket_by_id") 'pass procedure name db.AddSQLDBCmdParameter("@TicketID", SqlDbType.BigInt, 3357) 'pass a parameter dr = db.UseSQLDBExecuteReader() 'grab the data If dr.HasRows() Then While dr.Read() MsgBox(dr("TicketID")) End While dr.Close() End If db.SetSQLDBCommand("select_ticket_ids") 'another procedure db.AddSQLDBCmdParameter("@ClientID", SqlDbType.Int, 1) 'parameters db.AddSQLDBCmdParameter("@FacilityID", SqlDbType.BigInt, 1) db.AddSQLDBCmdParameter("@bOpen", SqlDbType.Bit, 1) db.AddSQLDBCmdParameter("@bOnHold", SqlDbType.Bit, 1) dr = db.UseSQLDBExecuteReader() 'execute it While dr.Read() MsgBox(dr("TicketID")) End While dr.Close() End Sub
And that works for you ? So why doesnt it work for me ???




Reply With Quote