Alternative to SQL to Create MS Access Table?

G

Guest

I'm new to ADO.net so forgive me if this question seems obvious . . .

I want to programmatically create a table in an MS Access database. To do
this, I've implemented this code:

conn.Open();
string cmdText = "CREATE TABLE Respondents ([Index] Int
Primary Key, PollsterName Char(25), [Guid] Char(36), " +
"TimeCaptured Date, FirstName Char(25),
LastName Char(25), Address Char(75), City Char(30), " +
"StateProv Char(20), PostalCode Char(15),
AreaCode Char(5), TelNum Char(20), Sex Char(10), Age Byte)";
System.Data.OleDb.OleDbCommand cmd = new
System.Data.OleDb.OleDbCommand(cmdText, conn);
cmd.ExecuteNonQuery();
conn.Close();


But I'm wondering if there's a more object-oriented way to accomplish the
same thing?
 
C

Cor Ligthert [MVP]

Robert,

No there is not at the moment is all database handling done by SQL. script
And if it are thirth part tools, than it are all generators which create and
use SQL script

Cor
 
G

Guest

Thanks for the feedback, Cor. I can deal with the SQL script of course, but
it seems strange to me that MS didn't provide a comprehensive library for
dealing with MDB files.

Good thing that early on I decided to save my data in XML format. My
dealing with MDB files now is purely for export purposes.

--
Robert W.
Vancouver, BC
www.mwtech.com



Cor Ligthert said:
Robert,

No there is not at the moment is all database handling done by SQL. script
And if it are thirth part tools, than it are all generators which create and
use SQL script

Cor

Robert W. said:
I'm new to ADO.net so forgive me if this question seems obvious . . .

I want to programmatically create a table in an MS Access database. To do
this, I've implemented this code:

conn.Open();
string cmdText = "CREATE TABLE Respondents ([Index] Int
Primary Key, PollsterName Char(25), [Guid] Char(36), " +
"TimeCaptured Date, FirstName Char(25),
LastName Char(25), Address Char(75), City Char(30), " +
"StateProv Char(20), PostalCode Char(15),
AreaCode Char(5), TelNum Char(20), Sex Char(10), Age Byte)";
System.Data.OleDb.OleDbCommand cmd = new
System.Data.OleDb.OleDbCommand(cmdText, conn);
cmd.ExecuteNonQuery();
conn.Close();


But I'm wondering if there's a more object-oriented way to accomplish the
same thing?
 
N

Norman Yuan

There is no way built-in .NET/ADO.NET. However, you could use COM interop to
do that with ADOX, which is not as good and as complete as DAO with jet
database, but certainly, you can certainly create jet database/table with
ADOX in a somewhat OO approach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top