Harish
Harish

Reputation: 169

Visual Basic .Net - Query for Database

Is it possible to Create a New table in the Database using any Action. The application I have designed is based on DateTimePicker. Is it possible to Create a table "March", "April" so on, when the user selects March or April for the first time. So that records of that particular month will be updated in that particular table.

Upvotes: 0

Views: 170

Answers (1)

AYK
AYK

Reputation: 3322

Use a query similar to

SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'TheSchema' AND  TABLE_NAME = 'TheTable'

to find whether table exists. If it does not exist you can fire a query similar to :

CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",
... )

for creating a table. Then you know which table you created. Just fire relevant INSERT queries.

Note that all of the above SQL queries need to be fired using SqlCommand object.

Upvotes: 1

Related Questions