MNovy
December 8th, 2008, 01:54 AM
Hi,
I would like to add a new column in my MDB file with auto number, but I could not figure out
how to do that. Google was not helpful.
Currently I have a method which adds a new column to an existing MDB file and a given
table. Maybe my concept is wrong? Please have a look in my code:
string strDatabase = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " + fileName;
string strStatement = "ALTER TABLE "+tableName+" ADD COLUMN "+ columnName + " " +columnType +";";
OleDbConnection conn = new OleDbConnection(strDatabase);
OleDbCommand cmd = new OleDbCommand(strStatement);
cmd.Connection = conn;
try
{
conn.Open();
cmd = new OleDbCommand(strStatement);
cmd.Connection = conn;
cmd.ExecuteReader();
}
catch { }
finally
{
conn.Close();
}
I would like to add a new column in my MDB file with auto number, but I could not figure out
how to do that. Google was not helpful.
Currently I have a method which adds a new column to an existing MDB file and a given
table. Maybe my concept is wrong? Please have a look in my code:
string strDatabase = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " + fileName;
string strStatement = "ALTER TABLE "+tableName+" ADD COLUMN "+ columnName + " " +columnType +";";
OleDbConnection conn = new OleDbConnection(strDatabase);
OleDbCommand cmd = new OleDbCommand(strStatement);
cmd.Connection = conn;
try
{
conn.Open();
cmd = new OleDbCommand(strStatement);
cmd.Connection = conn;
cmd.ExecuteReader();
}
catch { }
finally
{
conn.Close();
}