SQL Connection Object Reference Not Set to Instance of an Object

symnAssunty

New Member
I am trying to load a connection to a database in a user control I am making and I get the error:\[code\]Object reference not set to an instance of an object.\[/code\]I cannot figure out why I am getting this error at all. When I reference the same connection in my page it works fine.Here is the code for the connection I am trying to make:\[code\] Dim myConnection As New SqlCeConnection("Data Source = " & Server.MapPath("~").ToString & "App_Data\Database.sdf")\[/code\]I have made the proper imports and I am using the new keyword and have tried it without the new keyword. The Database.sdf is inside the App_data folder inside the root. My thoughts are that I cannot reference a connection in a user control. If this is correct, please just confirm this for me. Thank you so much.Help me out!!!
 
Back
Top