We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,577 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Creating Database Dynamically

I want to create tables in database dynamically i.e at the click event of a button or any other event.
Suggest me HOW ?

Thank You

3
Contributors
3
Replies
1 Day
Discussion Span
4 Months Ago
Last Updated
5
Views
Question
Answered
Rahul47
Junior Poster in Training
66 posts since Jan 2013
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0

Look at the sql statements in this tutorial

Ancient Dragon
Achieved Level 70
Team Colleague
32,104 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,574
Skill Endorsements: 68

Below example is in MS SQL...same can be done in Access database just change the SQLCommant to OLEDBCommand

First open the connection and then

Dim myCommand As SqlCommand
myCommand = New SqlCommand("CREATE TABLE Tablename (col1 datatype1,col2 datatype2)", myconn) 'where myconn is the connection object
myCommand.ExecuteNonQuery()

'Keep adding the table names as many as u want
myCommand = New SqlCommand("CREATE TABLE Tablename2 (col1 datatype1,col2 datatype2)", myconn) 'where myconn is the connection object
myCommand.ExecuteNonQuery() 

.
.
.
.

CLose the connection

poojavb
Posting Pro
524 posts since Nov 2011
Reputation Points: 39
Solved Threads: 77
Skill Endorsements: 5

@poojavb:

In Fact I wanted to add table at the click event of the mouse which will take the table name from the user. And I have solved it.

I Appreciate your help.
Thanks a Lot.

Rahul47
Junior Poster in Training
66 posts since Jan 2013
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 3 Months Ago by Ancient Dragon and poojavb

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0627 seconds using 2.67MB