Solved

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

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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