Solved

programatically create table, add columns and assign primary key in VB.net

Posted on 2004-09-30
7
1,036 Views
Last Modified: 2012-06-21
I need to creat a MSAccess table programatically in vb.net

I know how to open a MS Access database using the conenction string
next
I need to creat table ( name = table1)

next I need to add columns programmatically on the fly
Column1, column2  and column2

next I need to assign primary key programatically for a combination of column1 and column2 together ( composite key) programatically on the fly

0
Comment
Question by:KumaraPrathipati
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Expert Comment

by:CleffedUp
ID: 12197070
I don't believe that MS Access supports composite keys.  As for the columns, you should be able to just use T-SQL:

ALTER TABLE myTable (
      ADD Column1 varchar(50),
      ADD Column2 int,
      ADD Column3 date)
0
 
LVL 18

Accepted Solution

by:
DotNetLover_Baan earned 125 total points
ID: 12197089
0
 
LVL 7

Assisted Solution

by:J_Mak
J_Mak earned 125 total points
ID: 12197395
Have a look at this useful link for creating tables programmatically:

http://www.freevbcode.com/ShowCode.asp?ID=5797

Hope that helps.

0
 

Expert Comment

by:Seamie_
ID: 21738222
Links in Accepted Answer no longer valid
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generate Unique ID in VB.NET 21 134
wrapping text in datagridview header columns 1 29
Datagridview column resizing 8 27
vb.net code 9 28
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question