Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initialize A Database

Status
Not open for further replies.

jayplus707

Programmer
Jul 29, 2002
17
0
0
US
How do you initialize a database? I know you can create it and the tables by executing various SQL statements, such as:

SqlCeEngine engine = new SqlCeEngine ("Data Source = " + strPath);
engine.CreateDatabase ();

SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "CREATE TABLE TestTbl(id int PRIMARY KEY, name ntext, URL nText, userID nText, password nText, notes nText)";
cmd.ExecuteNonQuery();

But I'm trying to create a database by first creating a dataset and then "updating" the empty database that I am connecting to. Is this possible? What are the pros and cons of doing this? Is it better to stick with SQL?
 
If the database doesn't exist then you can't connect to it.

In SQL Server, you'd have to connect to Master, then issue your CREATE DATABASE commands from there. Whether you want people connecting to Master is a separate issue.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top