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
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
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:
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.