Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I return SqlDataReader in Module
Message
From
20/05/2011 05:18:30
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
How can I return SqlDataReader in Module
Environment versions
Environment:
VB 9.0
OS:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01511205
Message ID:
01511205
Views:
99
Hi all,
i want to wirte a fucntion to return SqlDataReader in Module, but appear error, NullReferenceException was unhandled by user code.
And Troubleshooting tips: Use the "new" keyword to create an object instance.
I use vb.net , my table more data not nul,GetConnection is no problem , Anyone can give some idea to me , thank you .
Imports System.Data.SqlClient
Module CommonModule
            Public dr As SqlDataReader
           Public Function Selectdr(ByVal tablename As String, ByVal field As String, ByVal value As String, Optional ByVal tablename2 As String = "", Optional ByVal joinfield As String = "", Optional ByVal wherefield As String = "") As SqlDataReader
        Dim conn As SqlConnection = GetConnection()
    
        Try

       
                Dim sqlcmd As New SqlCommand("select * from syslib", conn)
            End If

            conn.Open()

            Return sqlcmd.ExecuteReader             < 'in this the compile display error

        Finally
            conn.Close()
            conn.Dispose()
        End Try
    End Function
End Module
Next
Reply
Map
View

Click here to load this message in the networking platform