473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SQL server database

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
Nov 20 '05 #1
4 1409
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.

"EMW" <so*****@microsoft.com> wrote in message news:3f**********************@dreader2.news.tiscal i.nl...
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
Nov 20 '05 #2
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
"EMW" <so*****@microsoft.com> wrote in message news:3f**********************@dreader2.news.tiscal i.nl...
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
Nov 20 '05 #3
EMW
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 news:%2****************@TK2MSFTNGP09.phx.gbl...
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.

"EMW" <so*****@microsoft.com> wrote in message news:3f**********************@dreader2.news.tiscal i.nl...
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
Nov 20 '05 #4
Bob
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

"EMW" <so*****@microsoft.com> wrote in message
news:3f**********************@dreader2.news.tiscal i.nl...
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

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nathan Sokalski | last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database capabilities of ASP and IIS. I am probably using some incorrect settings, but I am not sure what they are. Here is what...
2
by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an...
14
by: John Spiegel | last post by:
Hi all, I'm missing something, probably stupid, on connecting to a SQL Server database from an aspx file. I haven't really done much w/ SQL Server and suspect that it's a problem on that side. ...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
0
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
2
by: Tor Inge Rislaa | last post by:
Database on remote server On the remote server where my ASP.NET application is located there is no SQL Server or SQL Server Express. When I test my application locally it works fine because...
9
by: TC | last post by:
Like a lot of database developers, I often choose Jet for the back- end. I'm starting to worry about what will happen when Jet is deprecated. Ostensibly, Jet users like me must switch to SQL Server...
3
by: Lee T. Hawkins | last post by:
I am having a number of problems over the last two full days trying to get an ASP.NET 2.0 application to connect to a SQL Server 2005 database... First off, I built this application w/ Visual...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.