Results 1 to 7 of 7

Thread: [RESOLVED] The ConnectionString property has not been initialized..WHERE WHEN HOW?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    70

    Resolved [RESOLVED] The ConnectionString property has not been initialized..WHERE WHEN HOW?

    HI ALL
    i am using VBEXpress 2005
    CONTROLS PRESENT
    IDTextbox
    DataGridView
    Next_Button ( the value in the IDTextbox changes when i clik the next_button)
    LOAD_GRID_button

    I am able to connect to my m.db databse ( via code)
    I am alos able to display the result of my SQL_Query into my DataGridView the first time (..LOAD_GRID_button--cliked 1st time)

    but after going to the next value (CLICKING THE NEXT_BUTTON)
    and if i try to load the grid again (Clik Load_Grid the 2nd time.. i get the message
    """""The ConnectionString property has not been initialized.""""""
    if u need to see the code in my form pla see atachment query.txt
    Attached Files Attached Files
    Last edited by Deepa7476; May 8th, 2006 at 02:42 AM.

  2. #2
    Addicted Member phenom's Avatar
    Join Date
    Apr 2006
    Location
    UAE
    Posts
    233

    Re: The ConnectionString property has not been initialized..WHERE WHEN HOW?

    Quote Originally Posted by Deepa7476
    HI ALL
    i am using VBEXpress 2005
    CONTROLS PRESENT
    IDTextbox
    DataGridView
    Next_Button ( the value in the IDTextbox changes when i clik the next_button)
    LOAD_GRID_button

    I am able to connect to my m.db databse ( via code)
    I am alos able to display the result of my SQL_Query into my DataGridView the first time (..LOAD_GRID_button--cliked 1st time)

    but after going to the next value (CLICKING THE NEXT_BUTTON)
    and if i try to load the grid again (Clik Load_Grid the 2nd time.. i get the message
    """""The ConnectionString property has not been initialized.""""""
    if u need to see the code in my form pla see atachment query.txt
    Hi Deepa7476,

    i think you need to rest the DataTable and clear the DataGrid...

    VB Code:
    1. sql_table.Reset()
    2. sql_table.Dispose()
    hope this helps,

    Regards,
    =======================================
    If I helped you, Kindly Rate my post. Thanks
    -----------
    PHENOM

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    70

    Re: The ConnectionString property has not been initialized..WHERE WHEN HOW?

    hi Phenom
    .. not working
    Still same error

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

    Re: The ConnectionString property has not been initialized..WHERE WHEN HOW?

    You've created the connection outside the method but you're disposing it inside. That means that once you've executed that method once the connection object has been destroyed. There's no need to be destroying those objects as it's probably more resource-intensive to keep creating and destroying them all than it is to just create them once and only destroy them when you close the form. If you really do want to destroy the objects at the end of the method then you'd have to be creating them at the start, so that each time you execute the method they will be recreated.
    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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    70

    Re: The ConnectionString property has not been initialized..WHERE WHEN HOW?

    hi JMC
    thnx for the tip
    i just moved
    sql_con.open() to fORM_LOAD
    AND its working great..
    xcept a teeny bit of prob
    My DataGridView is getting loaded the 2nd time also.. except that... its getting appended to the existing records
    tried
    VB Code:
    1. DataGridView1.SelectAll()
    2.         DataGridView1.ClearSelection()
    3.  
    4.         DataGridView1.DataSource = sql_dataset
    5.         DataGridView1.DataMember = "ID_Details"
    sitll its getting apended..
    i want to delete theresult of prev query and upload the new one..

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

    Re: The ConnectionString property has not been initialized..WHERE WHEN HOW?

    If you Fill the DataSet without Clearing it then it will still contain the old records.
    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

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    70

    Re: The ConnectionString property has not been initialized..WHERE WHEN HOW?

    thnx jmc i added
    VB Code:
    1. Private Sub Button_NEXT_Click()
    2. sql_dataset.clear()
    3. end sub
    working great now...
    every time i clik next to to go to the next record..the DGV is empty and on loading everyintg is dispalyed as fresh data
    thnks

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