Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I return SqlDataReader in Module
Message
De
20/05/2011 05:18:30
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
How can I return SqlDataReader in Module
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01511205
Message ID:
01511205
Vues:
101
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform