0

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.

1
  • 1
    Why not a single table 'dates' with 'month' column? This will prevent to you to create tables dynamically. Commented Apr 16, 2012 at 8:49

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.