Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a DataAccess Layer
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Creating a DataAccess Layer
Divers
Thread ID:
00682972
Message ID:
00682972
Vues:
87
I've never created a DataAccess layer and am attempting to do one now before I get to far along. So I thought I would
start off my creating a DataObjectVB class, with multiple functions. The first function I am trying to build is the
getConnection. This would return me a oledbConnection object. But when I try to run my code I get a null exeception error. I'm hoping someone might spot what I am missing, or have an example of a datalayer class. Below is the code:
'Login Button Code
Dim oDataConn As DataObjectVB
Dim lcSQL As String
Dim oConn As OleDb.OleDbConnection
Dim goView As Data.DataView
Dim iRecords As Integer
Dim cStatusText As String
Dim docID As String

'Get the connection string and sql statement

docID = txtUserName.Text
Session("UserID") = docID

lcSQL = "Select rtrim(lastname)+', '+rtrim(firstname) as docname, isnull(password,' ') as password, isnull(logincount,0) as logincount, isnull(lastlogin, ' ') as lastlogin, remaccess,remschedule from coper where isactive=1 and PerTypeID=1 and coPerID=" & docID


oConn = oDataConn.GetConnection()
Last Line causes error:
-- Error Message: NullReferenceException: Object reference not set to an instance of an object

Code for oDataConn.GetConnection()
    Public Function GetConnection() As OleDb.OleDbConnection
        Dim lcConnectionString As String
        lcConnectionString = "provider=sqloledb.1;server=cqi-termserv;uid=ctore;pwd=cqi$$;database=ctore"

        Dim lcSQL As String
        Dim oConn As OleDb.OleDbConnection

        oConn = VFPToolkit.vfpData.SqlConnect(lcConnectionString)

        Return oConn

    End Function
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform