0

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
5
Views
4 Years
Discussion Span
Last Post by Rahul47
0

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

0

@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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.