c#+ create Access database table programmetically

csharp , db Adelaide, Australia
  • 12 years ago

    hi frens

    i need to create a new table in Access database from C# code. i tried following code but it says " Syntax error in CREATE statement".

     

    string t-name= "newtable"; 

       string command2= "CREATE TABLE t_name(id INTEGER PRIMARY KEY IDENTITY, name TEXT(50) NOT NULL, status CHAR(50))";
                        OleDbCommand command3 = new OleDbCommand(command2, con);
                        command3.Connection = con;
                        command3.CommandText = command2;
                        int r = command3.ExecuteNonQuery();
     

    Thanks

    Radhika                         

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“XML is like violence - if it's not working for you, you're not using enough of it.”