473,699 Members | 2,273 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 1423
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
4453
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 (Intel X8 6)
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 also have SQL Server 2000 (SP2) in three Windows-2000 servers. All work fine. Recently, we get a...
14
1855
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: SqlConnection objConnection =
12
2782
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 servers, for both asp.net and sql server.
0
3919
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 one tell me how to set TCP\IP connection protocol on server for particular instance. Becuase I think
2
6956
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
2092
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 connecting to the database. I have done the preparation on my SQL Server to allow remote connection to the...
9
3007
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 other words, how will we create multi-user apps which use a file server to share data and don't...
3
3257
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 development server (with both the SQL and IIS servers on the same box) running on: Windows Server...
0
9199
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8945
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8902
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7787
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6550
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5889
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4641
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3075
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
3
2016
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.