Results 1 to 7 of 7

Thread: [RESOLVED] DataSet not connecting during runtime

  1. #1

    Thread Starter
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631

    Resolved [RESOLVED] DataSet not connecting during runtime

    I have a dataset that is able to return information during design-time via the "preview data" feature. However, the same dataset returns an error:

    Code:
    System.Data.OleDb.OleDbException was unhandled
      ErrorCode=-2147467259
      Message="Could not find file 'h:\Personal Folder\Visual Studio 2008\Projects\Winsock_Communication\Winsock_Communication\bin\Debug\mapper.mdb'."
    It makes no sense to me that it would work during design but not during run-time. Also, the path specified in the "message" section is incorrect but my connection string is correct (how else could it return the correct data during design)?

    Let me know if further information is necessary. This is the only dataset in my project.
    Last edited by Shawn N; Jan 7th, 2009 at 05:08 PM.
    Please rate my post.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: DataSet not connecting during runtime

    Have you set the connection string to use a relative path rather than an absolute path? That may explain why it's looking in the bin/debug folder at runtime.

  3. #3

    Thread Starter
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631

    Re: DataSet not connecting during runtime

    Yes & I realized that shortly after I made my initial post. I've changed the location of the database & updated the connection string so that it is outside of the project environment.

    This has fixed the problem reading, but now I can't add new records.

    Code:
    rowNewFIR.FIRName = txtFIR.Text
                rowNewFIR.Country = CountriesTableAdapter.GetCountryID(cmbCountry.Text).Item(0).ID
    
                Debug.Print(My.Settings.mapperConnectionString)
                MapperDataSet.FIR.Rows.Add(rowNewFIR)
    Debug.Prints "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="h:\Personal Folder\mapper.mdb" which is the correct path. Nothing enters into the database though. Thoughts??
    Please rate my post.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: DataSet not connecting during runtime

    I wouldn't know for sure.

    You've got a .Rows.Add() statement in there to add a row to the dataset, but where are you saving it to the database?

  5. #5

    Thread Starter
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631

    Re: DataSet not connecting during runtime

    Ummmm...I didn't know there was save statement. Yes I'm blushing.

    Can you help me out with that line?
    Please rate my post.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: DataSet not connecting during runtime

    Well, it really depends on how the dataset was populated; If done the conventional way, you'd have to call the DataAdapter's Update method or the TableAdapter's Update method.

  7. #7

    Thread Starter
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631

    Re: DataSet not connecting during runtime

    I replaced the line
    Code:
    MapperDataSet.FIR.Rows.Add(rowNewFIR)
    with

    Code:
    FIRTableAdapter.Insert(...)
    Thank you for pointing me in the right direction.
    Please rate my post.

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