H
Hasani
OK, I'm trying to programmatically create an Access database/mdb file but
CreateDb(string) always returns false. I don't know what I'm doing wrong, is
it my extern signature?
Thx in advance
my references:
http://msdn.microsoft.com/library/d...matically_configuring_an_odbc_data_source.asp
http://support.microsoft.com/defaul...port/kb/articles/q149/5/58.asp&NoWebContent=1
[DllImport("ODBCCP32.DLL")]
private static extern bool SQLConfigDataSource(
IntPtr hwndParent,
uint fRequest,
[MarshalAs(UnmanagedType.LPStr)] string lpszDriver,
[MarshalAs(UnmanagedType.LPStr)] string lpszAttributes
);
public static bool CreateDb(string dbName)
{
const string driver = @"Microsoft Access Driver (*.mdb)";
const int ODBC_ADD_DSN = 1;
string path = Environment.CurrentDirectory + "\\" + dbName + "
General";
return SQLConfigDataSource(IntPtr.Zero, ODBC_ADD_DSN, driver,
"CREATE_DB=" + path);
}
CreateDb(string) always returns false. I don't know what I'm doing wrong, is
it my extern signature?
Thx in advance
my references:
http://msdn.microsoft.com/library/d...matically_configuring_an_odbc_data_source.asp
http://support.microsoft.com/defaul...port/kb/articles/q149/5/58.asp&NoWebContent=1
[DllImport("ODBCCP32.DLL")]
private static extern bool SQLConfigDataSource(
IntPtr hwndParent,
uint fRequest,
[MarshalAs(UnmanagedType.LPStr)] string lpszDriver,
[MarshalAs(UnmanagedType.LPStr)] string lpszAttributes
);
public static bool CreateDb(string dbName)
{
const string driver = @"Microsoft Access Driver (*.mdb)";
const int ODBC_ADD_DSN = 1;
string path = Environment.CurrentDirectory + "\\" + dbName + "
General";
return SQLConfigDataSource(IntPtr.Zero, ODBC_ADD_DSN, driver,
"CREATE_DB=" + path);
}