I tried to set the type of the database in a control that reside in a
control library.
I'm using Factory class.When I run the code in User control test container I
receive the error:
"Object reference not set to an instance of an object"
I don't know what is happening .If i try the same code but in a regular
project (from a windows form) is running but when i try this code from a
control that reside in a control library is not working.
The code is:
Imports System
Imports System.Data
Imports System.Data.Com mon
Imports System.Configur ation
Public Class NrSystemForAcco unts
Private mConnectionStri ng As String
Private mFactoryName As String
Private mFactory As DbProviderFacto ry
Private mFactoryConnect ion As DbConnection
Private mFactoryCommand As DbCommand
Private mDataAdapter As DbDataAdapter
Private Sub SetFactory(ByVa l DataBaseConnect ionName As String)
____________ here at this first line I have the error message : Object
reference not set to an instance of an object
mConnectionStri ng =
ConfigurationMa nager.Connectio nStrings(DataBa seConnectionNam e).ConnectionSt ring.ToString()
mFactoryName =
ConfigurationMa nager.Connectio nStrings(DataBa seConnectionNam e).ProviderName .ToString()
mFactory = DbProviderFacto ries.GetFactory (mFactoryName)
End Sub
Private Sub NrSystemForAcco unts_Load(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load
Me.SetFactory(" DatabaseConnect ion1")
endsub
endclass
Can someone tell me what is happening ?How I can correct this code?
Thank you,
Mihai
control library.
I'm using Factory class.When I run the code in User control test container I
receive the error:
"Object reference not set to an instance of an object"
I don't know what is happening .If i try the same code but in a regular
project (from a windows form) is running but when i try this code from a
control that reside in a control library is not working.
The code is:
Imports System
Imports System.Data
Imports System.Data.Com mon
Imports System.Configur ation
Public Class NrSystemForAcco unts
Private mConnectionStri ng As String
Private mFactoryName As String
Private mFactory As DbProviderFacto ry
Private mFactoryConnect ion As DbConnection
Private mFactoryCommand As DbCommand
Private mDataAdapter As DbDataAdapter
Private Sub SetFactory(ByVa l DataBaseConnect ionName As String)
____________ here at this first line I have the error message : Object
reference not set to an instance of an object
mConnectionStri ng =
ConfigurationMa nager.Connectio nStrings(DataBa seConnectionNam e).ConnectionSt ring.ToString()
mFactoryName =
ConfigurationMa nager.Connectio nStrings(DataBa seConnectionNam e).ProviderName .ToString()
mFactory = DbProviderFacto ries.GetFactory (mFactoryName)
End Sub
Private Sub NrSystemForAcco unts_Load(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load
Me.SetFactory(" DatabaseConnect ion1")
endsub
endclass
Can someone tell me what is happening ?How I can correct this code?
Thank you,
Mihai