ConnectionString problems

  • Thread starter Thread starter TonyB
  • Start date Start date
T

TonyB

I'm connecting to a access database which is in the \bin\debug folder in my
project directory. So if I set myproject/settings/myDatabaseConnectionString
to "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|\myDatabase.mdb" and configure a dataset to use this
connection string and load values from myTable in that database, and add the
tableadapter to a form all works ok, and I see the table listed in my form.
However if I preview data by right click the Fill,GetData() sql query in the
tableadapter, I get an error stating
"myDatabaseDataSet.myTable.Fill,GetData() could not be previewed. followed
by a could not find file "C:\Document and
Settings\....myproject\myproject\mydatabase.mdb" (missing \bin\debug in
path)
If I set the connection string to "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|\bin\object\myDatabase.mdb" the preview works, but the
application has an exception error stating
'C:\Documents and Settings\tonyb\My
Documents\VBSamples\myProject\myProject\bin\Debug\bin\debug\myDatabase.mdb'
is not a valid path. (\bin\Debug repeated)
So the application seems to believe |DataDirectory| points to
projectpath\bin\debug\, but the preview windows seem to assume
|DataDirectory| points to projectpath\ ?
What am I doing wrong ?
 
TonyB said:
I'm connecting to a access database which is in the \bin\debug folder in
my project directory. So if I set
myproject/settings/myDatabaseConnectionString to
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|\myDatabase.mdb" and configure a dataset to use this
connection string and load values from myTable in that database, and add
the tableadapter to a form all works ok, and I see the table listed in my
form.
However if I preview data by right click the Fill,GetData() sql query in
the tableadapter, I get an error stating
"myDatabaseDataSet.myTable.Fill,GetData() could not be previewed. followed
by a could not find file "C:\Document and
Settings\....myproject\myproject\mydatabase.mdb" (missing \bin\debug in
path)
If I set the connection string to "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|\bin\object\myDatabase.mdb" the preview works, but
the application has an exception error stating
'C:\Documents and Settings\tonyb\My
Documents\VBSamples\myProject\myProject\bin\Debug\bin\debug\myDatabase.mdb'
is not a valid path. (\bin\Debug repeated)
So the application seems to believe |DataDirectory| points to
projectpath\bin\debug\, but the preview windows seem to assume
|DataDirectory| points to projectpath\ ?
What am I doing wrong ?
I fixed this by removing the data source and connection string and adding
new data source, and select do not copy database option in the add
datasource wizard.
 
Back
Top