Results 1 to 5 of 5

Thread: ERROR: ConnectionString Property not initialized

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    6

    Exclamation ERROR: ConnectionString Property not initialized

    So I believe this problem started when I deleted a dataset and brought it back into Visual Studio 2013. I'm using a mysql backend with this application, so I have the dotconnect for mysql extension. The connection string I was using worked perfectly fine until I redid the dataset. Here is my app.config:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <configSections>
        </configSections>
        <connectionStrings>
            <add name="RMSteel.My.MySettings.RMSteelConnectionString" connectionString="User Id=rmsteel;Password=password;Host=192.168.0.46;Database=RMSteel;Persist Security Info=True"
                providerName="Devart.Data.MySql" />
        </connectionStrings>
        <startup>
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
               
        </startup>
    </configuration>
    (Don't worry, this application is on an intranet with no internet connection whatsoever, that's why I left the whole connection string).
    So the build succeeds but after the build when it is loading the first form that's when it fails. I have been fiddling around with different things. This line works when the form loads:
    Code:
    MsgBox(RMSteel.My.Settings.RMSteelConnectionString)
    And this line is where it throws the errors:
    Code:
     Me.EmployeeTableAdapter.Fill(Me.RMSteelDataSet.Employee)
    These are the first two lines in the form load function.
    I'm really at a loss here, and need to get this fixed since I've done a ton of work on this application already. I'm the only developer here so I don't have a superior to ask.
    Any help is greatly appreciated. I did a stack overflow post but no one has answered, I will link to it just in case there is extra info there.
    http://stackoverflow.com/questions/2...ot-initialized

  2. #2

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    6

    Re: ERROR: ConnectionString Property not initialized

    So, I think I've narrowed it down to a table adapter issue. I commented out the table adapter line, and the first form loaded and worked fine (It uses queries to log in so I know that the connection string is working fine). Once it gets to another form with a table adapter then it throws the error again.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: ERROR: ConnectionString Property not initialized

    Your Fill method is almost certainly throwing an exception but exceptions in the Load event handler are swallowed on 64-bit machines. Try wrapping the code of the Load event handler in a Try...Catch block and then you can access the exception and get all the details it provides. That will give a much clearer indication of the root cause of the issue and we can zero in and address it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    6

    Re: ERROR: ConnectionString Property not initialized

    Thank you so much for the reply. I tried putting a try...catch block completely around the load event handler, but it says that I cannot place a try outside of a method:
    Code:
     Try
        Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            MsgBox(RMSteel.My.Settings.RMSteelConnectionString)
            'TODO: This line of code loads data into the 'RMSteelDataSet.Employee' table. You can move, or remove it, as needed.
    
            Me.EmployeeTableAdapter.Fill(Me.RMSteelDataSet.Employee)
            'ensure login textboxes start empty
    
    
            TextBox1.Text = ""
            TextBox2.Text = ""
            
    
        End Sub
        Catch ex as Exception
        MsgBox(ex.Message)
        End Try
    I'm still a little new to VB so bear with me.
    Then I tried wrapping the load handler within another method and it wasn't letting me do that either.
    Code:
    Public Sub test()
        Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            MsgBox(RMSteel.My.Settings.RMSteelConnectionString)
            'TODO: This line of code loads data into the 'RMSteelDataSet.Employee' table. You can move, or remove it, as needed.
    
            Me.EmployeeTableAdapter.Fill(Me.RMSteelDataSet.Employee)
            'ensure login textboxes start empty
    
    
            TextBox1.Text = ""
            TextBox2.Text = ""
    
    
        End Sub
        End Sub
    So, When I wrap just the fill in the try catch, it gives me the same connection string error.

  5. #5
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: ERROR: ConnectionString Property not initialized

    I am sure what jmc ment was to put the Try-Catch wrapping all the code "inside" the load event.

    Code:
    Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        Try
            MsgBox(RMSteel.My.Settings.RMSteelConnectionString)
            'TODO: This line of code loads data into the 'RMSteelDataSet.Employee' table. You can move, or remove it, as needed.
    
            Me.EmployeeTableAdapter.Fill(Me.RMSteelDataSet.Employee)
            'ensure login textboxes start empty
    
    
            TextBox1.Text = ""
            TextBox2.Text = ""
    
        Catch
            'your catch code here
        End Try   
    
    End Sub
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width