473,545 Members | 1,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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;d atabase=SiteLis t")
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 1416
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("Cre ate Database MyDatabase", connection)
command.Execute NonQuery()

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*****@micros oft.com> wrote in message news:3f******** **************@ dreader2.news.t iscali.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;d atabase=SiteLis t")
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\da ta\saledat.mdf' ,
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Sales_log',
FILENAME = 'c:\program files\microsoft sql server\mssql\da ta\salelog.ldf' ,
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
You'll specify where the files are stored...

HTH,

Bill
"EMW" <so*****@micros oft.com> wrote in message news:3f******** **************@ dreader2.news.t iscali.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;d atabase=SiteLis t")
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******** ********@TK2MSF TNGP09.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("Cre ate Database MyDatabase", connection)
command.Execute NonQuery()

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*****@micros oft.com> wrote in message news:3f******** **************@ dreader2.news.t iscali.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;d atabase=SiteLis t")
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*****@micros oft.com> wrote in message
news:3f******** **************@ dreader2.news.t iscali.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;d atabase=SiteLis t")
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
4436
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 I am currently doing: When I run sqlservr.exe I see the following: 2003-12-19 15:51:28.20 server Microsoft SQL Server 2000 - 8.00.760...
2
2133
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 issue with Active Directory. Our network consists of Windows-2000 Servers (SP 4) and Windows-2000 workstations and Windows-XP workstations. We...
14
1837
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. I've installed the SQL Server developer edition locally and do have a pubs database. The connection I'm attempting is the following: ...
12
2757
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 both the iis and sql server in a single machine. Not too long ago, the machine had some hardware problems, and management has decided to purchase new...
0
3908
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 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any...
2
6932
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
2
2076
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 I have the SQL Server Express 2005 on my computer, but when I deploy it I am getting error message telling me that there are some problems...
9
2996
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 (or MSDE / SQL Express), but there's something I just don't understand. Without Jet, how will we create file server database applications? In...
3
3251
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 Studio 2005 SP1 and had it working perfectly on my Windows XP machine on SQL Server 2005 Express. I decided to publish this application to a test...
0
7475
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7409
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
5982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1900
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
720
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.