Solved

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

Posted on 2004-09-30
7
1,032 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now