DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Posts
    5

    create a runtime table in Ms Access database

    I want to create table at runtime for an existing Ms Access database using ASP.net 2.0 and C#.
    Can anyone please guide me through it ?
    Last edited by arpd2005; 12-11-2006 at 09:26 AM.

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    See the below newsgroup post. You may also want to take a look some Jet SQL DDL articles:

    http://tinyurl.com/y6vq5j

    http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx
    http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  3. #3
    Join Date
    May 2006
    Posts
    5

    create a runtime table in Ms Access database

    void createTable(string connString, string tableName)
    {
    try
    {
    OleDbConnection con = new OleDbConnection(connString);
    OleDbCommand cmd = con.CreateCommand();

    string cmdText = String.Format("CREATE TABLE {0} (dno int primary key, dname char(15), grade int, avg int)",tableName);

    cmd.CommandType = CommandType.Text;
    cmd.CommandText = cmdText;
    con.Open();

    cmd.ExecuteNonQuery();
    }
    catch (Exception e)
    {
    // Process error
    log.Error("Exception occured", e);
    }
    finally
    {
    // Close connection if open

    try { if (con != null) con.Close(); }
    catch (Exception ex)
    {
    log.Warn("Unable to close connection - exception occured.", ex);
    }
    }
    }

Similar Threads

  1. How would u do it (design question) ?
    By Joe in forum Database
    Replies: 17
    Last Post: 04-04-2003, 04:55 PM
  2. Replies: 5
    Last Post: 09-16-2002, 01:03 PM
  3. Access 97 to 2000 Conversion Error
    By Michelle in forum VB Classic
    Replies: 8
    Last Post: 04-19-2002, 05:01 PM
  4. Multi-User access for access database
    By Dave W in forum VB Classic
    Replies: 5
    Last Post: 10-26-2001, 11:29 AM
  5. Temporary table in Access database
    By Marcus in forum VB Classic
    Replies: 1
    Last Post: 01-06-2001, 09:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links