[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.
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.
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??
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?
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?
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.
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.