figured this much out...
using a DSN for an app that we might want to distribute
to end users just didn't seem right. we would have to
get the user to set the DSN up or programmitically set
one up in our code. there had to be a better way.
after searching the past few hours, the best solution i
found so far was to not put anything down as a DSN.
ie in the RecordSet class, the GetDefaultConnection
method, remove the name of your DSN.
this compiles and when run, asks for you to select a
DSN or create one.
pretty lame!
i gave up trying to find how to setup a connection
string and after alot of playing and fiddling, set up
a "File DSN". seemed an OK solution, but still not good
enough!
ANYWAY.... came up with this (replace
GetDefaultConnection in the RecordSet class to...
CString CDbSet::GetDefaultConnect()
{
CString connString;
connString = "ODBC;DRIVER=Microsoft Access Driver *.mdb);" +
connString += "UID=admin;";
connString += "UserCommitSync=no;";
connString += "Threads=3;";
connString += "SafeTransactions=0;";
connString += "PageTimeout=5;";
connString += "MaxScanRows=8;";
connString += "MaxBufferSize=2048;";
connString += "FIL=MS Access;";
connString += "DriverId=25;";
connString += "DBQ=alex.mdb;";
return connString;
}
this is basically just the contents of the file DSN,
but removed the absolute path at DBQ=.... and the
DEFAULTLOCATION
seems to be working great! jsut wondering now how users
who don't have access setup on their machines would use
such an app? is there a way to setup a ODBC driver on
their machine? is this legal and/or ethical? is it
required?
note also, that if running in debug mode, the db needs
to be in the folder ABOVE Debug folder for the relative
path to work, otherwise use \ to escape folders
ie c:\\windows\\mydbs\\mydb.mdb
good luck!
alex