Hi,
I generated a class library as below.
To get the DB connection, I included above DLL in my form class as below but I am getting "Object reference not set to an instance of an object" Error.
I would really appreciate if you could tell me the issue ??
I generated a class library as below.
VB.NET:
Public Class Class1
Public connString As String
'Public Sub New()
'End Sub
Public Function getDBConnection() As String
Try
Dim connObj As Object = ConfigurationManager.ConnectionStrings("DatabaseConnectionString")
connString = connObj.ToString
Catch ex As Exception
End Try
'connString = ConfigurationManager.ConnectionStrings("DatabaseC onnectionString").ConnectionString
Return connString
End Function
End Class
VB.NET:
Partial Class _Default
Inherits System.Web.UI.Page
Private classObj As New DBShareLib.Class1
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Dim con As New OracleConnection(classObj.getDBConnection().ToString
Dim dbval As String = classObj.getDBConnection().ToString
'con.Open()
'Response.Write("Connection is Success")
'con.Close()
Response.Write(dbval)
End Sub
End Class
Last edited by a moderator: