I am trying to generate rules form of output from user data.that output i have to store in sql database.so when each time , user is giving different data for processing, i have to create a new database for storing the rules from their data.
how can i do this dynamic creation of database when needed.

Recommended Answers

All 6 Replies

Use Create Database SQL statement.

how i can give every time a new name to the database created so that those databases created can be saved for long time.the name of database how it can be passed

You have to figure out how your dbs should be named and pass that name to Create Database.

For some strange reason I'm guessing you are following a wrong path here.
Can you explain again why each users output rules have to go to a different db? Wouldn't a table with different records per user do? Can you elaborate on what type of data you have to store in each db?

Hi,
I'm with adam_k; why isn't a new table per user being used instead of an entire new database per user - that seems excessive. If you do need different tables you will need to figure out a naming strategy that will create unique names (but still following some set rules as you'll obviously need to access these databases again at some point).
A better understanding of what you're trying to store would help us out.

yes sir,i was mistaken.It is good to create table instead of database every time.
How can i check in asp.net c# application that whether a sql table exists or not.if it exists,drop it and create new one.
else if it doesn't exists,simply create it.

how can i do it sir?

IF EXISTS(SELECT name FROM sys.tables
  WHERE name = 'T')
BEGIN
DROP TABLE T
END
CREATE TABLE T (
c1 nvarchar(max),
c2 nvarchar(max)
)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.