ConnectionString property has not been initialized

acidflash

Active member
Joined
Oct 23, 2008
Messages
29
Programming Experience
1-3
Hello,

I wrote a vb.net 2008 database program, and I set the connectionstring to be remote, ie: "\\xx.yy.zz.aa\whatever\database.mdb". Now whenever i launch my program, it gives me the following error, and yes I read the thread and wasnt able to solve it still... and I have been looking online for a couple of hours

The ConnectionString property has not been initialized.
VB.NET:
See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidOperationException: The ConnectionString property has not been initialized.
   at System.Data.OleDb.OleDbConnection.PermissionDemand()
   at System.Data.OleDb.OleDbConnectionFactory.PermissionDemand(DbConnection outerConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OleDb.OleDbConnection.Open()
   at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
   at Broadband_Management_System.LoginForm1.LoginForm1_Load(Object sender, EventArgs e) in C:\Users\Owner\Desktop\DPL Program\Broadband Management System\Broadband Management System\LoginForm1.vb:line 18
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Broadband Management System
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/Owner/Desktop/DPL%20Program/Broadband%20Management%20System/Broadband%20Management%20System/bin/Release/Broadband%20Management%20System.exe
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Transactions
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

I have already done connection.open() and in all honesty i am out of ideas, any help would be much appreciated.

acidflash
 
VB.NET:
Public Class LoginForm1
    Private Sub Window_Unload(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        PasswordsConnection.Close()
    End Sub

    Private Sub LoginForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' TODO: Insert code to perform custom authentication using the provided username and password 
        ' (See http://go.microsoft.com/fwlink/?LinkId=35339).  
        ' The custom principal can then be attached to the current thread's principal as follows: 
        '     My.User.CurrentPrincipal = CustomPrincipal
        ' where CustomPrincipal is the IPrincipal implementation used to perform authentication. 
        ' Subsequently, My.User will return identity information encapsulated in the CustomPrincipal object
        ' such as the username, display name, etc.
        PasswordsConnection.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =\\142.23.231.1\Broadband Management System\SS Solutions.mdb"
        PasswordsConnection.Open()
        PasswordsString = "SELECT * FROM Passwords"
        PasswordsDA = New OleDb.OleDbDataAdapter(ClientsString, ClientsConnection)
        PasswordsDA.Fill(PasswordsDS, "PasswordsMain")
        PasswordsInc = 0
    End Sub

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim EnteredPassword As String
        Dim EnteredUsername As String
        Dim passwordOLEDB As New OleDb.OleDbCommand
        Dim PasswordAttempts As Integer
        PasswordAttempts = 0
        EnteredUsername = UsernameTextBox.Text
        EnteredPassword = PasswordTextBox.Text
        passwordOLEDB.CommandText = "SELECT * FROM Passwords WHERE AppUsername='" & EnteredUsername & "' AND AppPassword='" & EnteredPassword & "';"
        passwordOLEDB.Connection = PasswordsConnection
        Dim rdrOLEDB As OleDb.OleDbDataReader
        rdrOLEDB = passwordOLEDB.ExecuteReader
        If rdrOLEDB.Read = True Then
            If (EnteredUsername = "Manager") Then
                PasswordsConnection.Close()
                Me.Hide()
                Main.Show()
            ElseIf (EnteredUsername = "Reception") Then
                PasswordsConnection.Close()
                Me.Hide()
                Reception.Show()
            ElseIf (EnteredUsername = "Service") Then
                PasswordsConnection.Close()
                Me.Hide()
                Service.Show()
            End If
        ElseIf rdrOLEDB.Read = False Then
            PasswordAttempts += 1
            If (PasswordAttempts < 3) Then
                MessageBox.Show("Incorrect password", "Authentication", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            ElseIf (PasswordAttempts >= 3) Then
                MessageBox.Show("Incorrect password. Too many failed attempts. Exiting", "Too many failed attempts!", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Me.Close()
            End If
        End If
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

End Class
 
have you verified that the account youre running the app under has permission to access the file (windows ntfs perms)
verify also the permissions of the .net assembly (.net apps have a security sandbox they run in and need specific perms to access net resources sometimes..)

follow the dw3 link in my sig, section "creating a simple daata app" and see if the problem still occurs
 
cjard,

i can access the database fine, i can read and write to it if i click continue. I have all the proper permissions, its just an issue of that message popping up everytime i launch my program. Every other aspect works fine, i can read, write, and edit the remote database fine. I am curious as to why the message is popping up, and how to get rid of it.

acidflash
 
System.InvalidOperationException: The ConnectionString property has not been initialized.

at Broadband_Management_System.LoginForm1.LoginForm1_Load(Object sender, EventArgs e) in C:\Users\Owner\Desktop\DPL Program\Broadband Management System\Broadband Management System\LoginForm1.vb:line 18

I have already done connection.open() and in all honesty i am out of ideas, any help would be much appreciated.
VB.NET:
    Private Sub LoginForm1_Load(.....
        PasswordsDA = New OleDb.OleDbDataAdapter([COLOR="red"]ClientsString[/COLOR], [COLOR="red"]ClientsConnection[/COLOR])
line 18:        PasswordsDA.Fill(PasswordsDS, "PasswordsMain")
Is ClientsString and ClientsConnection variables initialized?
I have already done connection.open()
That was not the connection you were using.
 
JohnH,

In all honesty I COMPLETELY overlooked the fact that I called ClientString, and ClientConnection without first opening them in that portion. I got too lazy to make a new PasswordString, and PasswordConnection since it was the same database.That gives me a place to start, thank you VERY MUCH, that is much appreciated. I will work on a few fixes, and keep you posted, thank you very much for that. Great work!

acidflash
 
Back
Top