A
alexttp
Yeah, yeah, once again about this error...
I saw numerous threads about this error, suggesting there are
limitations in Access 2000 GUI and that I need to use OLEDB rather
than ODBC in order to perform "ALTER TABLE" statements... But it stil
doesn't work.
The problem (uhm... well, this is the reason why I still have this
problem appearing) is that I try to do that from a C# program, and I
couldn't find any sample showing how to do that SUCCESSFULLY...
Here's a snippet from the code:
using System.Data.OleDb;
....
public DataSet ExecSQL(string i_strSQL)
{
DataSet oDs = new DataSet();
try
{
OleDbCommand oCommand = new OleDbCommand(i_strSQL, m_oConnection);
OleDbDataAdapter oAdapter = new OleDbDataAdapter(oCommand);
if(m_oConnection.State != ConnectionState.Open)
{
m_oConnection.Open();
}
oAdapter.Fill(oDs);
}
catch(Exception ex)
{
...
}
return oDs;
}
where m_oConnection is defeined as follows:
protected OleDbConnection m_oConnection = null;
m_oConnection = new OleDbConnection(m_strConnectionString);
m_oADOConnection = new ConnectionClass();
m_strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=D:\db.mdb"
m_oADOConnection.Open(m_strConnectionString, string.Empty,
string.Empty, 0);
So I DO use OLEDB, but still keep getting the error when trying to
execute a statement that uses the "DEFAULT" keyword:
"ALTER TABLE Catalog
ADD COLUMN [NewSimpleIntField] int NOT NULL DEFAULT 110 WITH VALUES ;"
Running out of ideas, I even tried using the ADODB library:
using ADODB;
m_oADOConnection = new ConnectionClass();
m_oADOConnection.Open(m_strConnectionString, string.Empty,
string.Empty, 0);
object o = null;
m_oADOConnection.Execute(i_strSQL, out o, 1);
.... but this resulted in the same error, eventually. :-(
Any help would be GREATLY appreciated, since I'm really frustrated...
Alex
I saw numerous threads about this error, suggesting there are
limitations in Access 2000 GUI and that I need to use OLEDB rather
than ODBC in order to perform "ALTER TABLE" statements... But it stil
doesn't work.
The problem (uhm... well, this is the reason why I still have this
problem appearing) is that I try to do that from a C# program, and I
couldn't find any sample showing how to do that SUCCESSFULLY...
Here's a snippet from the code:
using System.Data.OleDb;
....
public DataSet ExecSQL(string i_strSQL)
{
DataSet oDs = new DataSet();
try
{
OleDbCommand oCommand = new OleDbCommand(i_strSQL, m_oConnection);
OleDbDataAdapter oAdapter = new OleDbDataAdapter(oCommand);
if(m_oConnection.State != ConnectionState.Open)
{
m_oConnection.Open();
}
oAdapter.Fill(oDs);
}
catch(Exception ex)
{
...
}
return oDs;
}
where m_oConnection is defeined as follows:
protected OleDbConnection m_oConnection = null;
m_oConnection = new OleDbConnection(m_strConnectionString);
m_oADOConnection = new ConnectionClass();
m_strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User
ID=Admin;Data Source=D:\db.mdb"
m_oADOConnection.Open(m_strConnectionString, string.Empty,
string.Empty, 0);
So I DO use OLEDB, but still keep getting the error when trying to
execute a statement that uses the "DEFAULT" keyword:
"ALTER TABLE Catalog
ADD COLUMN [NewSimpleIntField] int NOT NULL DEFAULT 110 WITH VALUES ;"
Running out of ideas, I even tried using the ADODB library:
using ADODB;
m_oADOConnection = new ConnectionClass();
m_oADOConnection.Open(m_strConnectionString, string.Empty,
string.Empty, 0);
object o = null;
m_oADOConnection.Execute(i_strSQL, out o, 1);
.... but this resulted in the same error, eventually. :-(
Any help would be GREATLY appreciated, since I'm really frustrated...
Alex