SQL server database

  • Thread starter Thread starter EMW
  • Start date Start date
E

EMW

How can I create a SQL server database in my VB.NET program?
I've MSSQLServer installed and running.

If a database is created, where is it stored?

I used the following code, didn't get any errors, but cannot find a new file:

Dim con As SqlConnection = New SqlConnection("server=(local);Integrated Security=SSPI;database=SiteList")
Dim cmdLijst As SqlDataAdapter = New SqlDataAdapter("CREATE DATABASE ", con)
'here some code to create the table?
'here some code to put the info from a dataset into the sql database?
con.close

Is with this code the database created?

thanks
Eric
 
No.

My VB is rusty but off the cuff ...

Dim connnection as New SqlConnection("server=(local); Integrated Security=SSPI"; database=master)
Dim command as New SqlCommand("Create Database MyDatabase", connection)
command.ExecuteNonQuery()

Then simply add the necessary commands to create your tables etc. It is probably a lot easier though to create the database from VS or Enterprise manager and then simply use it.

How can I create a SQL server database in my VB.NET program?
I've MSSQLServer installed and running.

If a database is created, where is it stored?

I used the following code, didn't get any errors, but cannot find a new file:

Dim con As SqlConnection = New SqlConnection("server=(local);Integrated Security=SSPI;database=SiteList")
Dim cmdLijst As SqlDataAdapter = New SqlDataAdapter("CREATE DATABASE ", con)
'here some code to create the table?
'here some code to put the info from a dataset into the sql database?
con.close

Is with this code the database created?

thanks
Eric
 
Check out BOL, but assuming you have the permissions, you'll just set the command text like:

USE master
GO
CREATE DATABASE Sales
ON
( NAME = Sales_dat,
FILENAME = 'c:\program files\microsoft sql server\mssql\data\saledat.mdf',
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Sales_log',
FILENAME = 'c:\program files\microsoft sql server\mssql\data\salelog.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO


You'll specify where the files are stored...

HTH,

Bill
How can I create a SQL server database in my VB.NET program?
I've MSSQLServer installed and running.

If a database is created, where is it stored?

I used the following code, didn't get any errors, but cannot find a new file:

Dim con As SqlConnection = New SqlConnection("server=(local);Integrated Security=SSPI;database=SiteList")
Dim cmdLijst As SqlDataAdapter = New SqlDataAdapter("CREATE DATABASE ", con)
'here some code to create the table?
'here some code to put the info from a dataset into the sql database?
con.close

Is with this code the database created?

thanks
Eric
 
Thanks, Martin.

The reason I need to do it programmaticly is because it is an conversion program, so after each conversion it creates a SQL database

rg,
Eric
"Martin Robins" <martin - robins @ ntlworld dot com> schreef in bericht No.

My VB is rusty but off the cuff ...

Dim connnection as New SqlConnection("server=(local); Integrated Security=SSPI"; database=master)
Dim command as New SqlCommand("Create Database MyDatabase", connection)
command.ExecuteNonQuery()

Then simply add the necessary commands to create your tables etc. It is probably a lot easier though to create the database from VS or Enterprise manager and then simply use it.

How can I create a SQL server database in my VB.NET program?
I've MSSQLServer installed and running.

If a database is created, where is it stored?

I used the following code, didn't get any errors, but cannot find a new file:

Dim con As SqlConnection = New SqlConnection("server=(local);Integrated Security=SSPI;database=SiteList")
Dim cmdLijst As SqlDataAdapter = New SqlDataAdapter("CREATE DATABASE ", con)
'here some code to create the table?
'here some code to put the info from a dataset into the sql database?
con.close

Is with this code the database created?

thanks
Eric
 
Bring up Enterprise Manager, right-click on an existing database, and select All
Tasks/Generate SQL Script. Go to the Options tab and in the Secutiry Scipting
Options section, check "Script database". Go back to the General tab and click
on the Preview button - you will get a complete script on how a database is
created with all its options using T-SQL. This can be placed directly in code,
or entirely in a stored procedure if you are comfortable with working with
dynamic sql.

Bob

How can I create a SQL server database in my VB.NET program?
I've MSSQLServer installed and running.

If a database is created, where is it stored?

I used the following code, didn't get any errors, but cannot find a new file:

Dim con As SqlConnection = New SqlConnection("server=(local);Integrated
Security=SSPI;database=SiteList")
Dim cmdLijst As SqlDataAdapter = New SqlDataAdapter("CREATE DATABASE ", con)
'here some code to create the table?
'here some code to put the info from a dataset into the sql database?
con.close

Is with this code the database created?

thanks
Eric
 
Back
Top