473,767 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create SQL Db on SQL server

Jon
Hi,

I have tried to create a new DB on the SQL Server but unsucessful..
I have looked at the microsoft "How to create SQL Database in vb.net", but
it doesn't seems to solve my problem.

below is the connection string that i used to create, but i get error saying
login has fails. I am sure the login works because i can read out data from
the SQL server no problem...

Dim conn As SqlConnection = New SqlConnection(" Initial Catalog= NewDB;" & _
"Data Source=SERVER-MACHINE;" & _
"UID=abcde; " & _
"PWD=abcde; "

Dim cmd0 As New SqlClient.SqlCo mmand("CREATE DATABASE ON PRIMARY " & _
"(NAME = NewDB, " & _
" FILENAME = 'D:\Program
Files\Microsoft SQL Server\MSSQL\Da ta\" & m_date & ".mdf', " & _
" SIZE = 2MB, " & _
" MAXSIZE = 10MB, " & _
" FILEGROWTH = 10%) " & _
" LOG ON " & _
"(NAME = " & m_date & "_log,
" & _
" FILENAME = 'D:\Program
Files\Microsoft SQL Server\MSSQL\Da ta\" & m_date & ".ldf', " & _
" SIZE = 1MB, " & _
" MAXSIZE = 5MB, " & _
" FILEGROWTH = 10%) ", conn)

so i wonder m i doing anything wrong???
Any help would be appreciated.

many thanks.
Nov 21 '05 #1
3 2269
To start with, the Initial Catalog can't point to a database that does
not yet exist. Use "master".

Secondly, once you create the database you will have to grant the user
permissions to access the database before you can then log into it.

Hope this helps....

Bob

Jon wrote:
Hi,

I have tried to create a new DB on the SQL Server but unsucessful..
I have looked at the microsoft "How to create SQL Database in vb.net", but
it doesn't seems to solve my problem.

below is the connection string that i used to create, but i get error saying
login has fails. I am sure the login works because i can read out data from
the SQL server no problem...

Dim conn As SqlConnection = New SqlConnection(" Initial Catalog= NewDB;" & _
"Data Source=SERVER-MACHINE;" & _
"UID=abcde; " & _
"PWD=abcde; "

Dim cmd0 As New SqlClient.SqlCo mmand("CREATE DATABASE ON PRIMARY " & _
"(NAME = NewDB, " & _
" FILENAME = 'D:\Program
Files\Microsoft SQL Server\MSSQL\Da ta\" & m_date & ".mdf', " & _
" SIZE = 2MB, " & _
" MAXSIZE = 10MB, " & _
" FILEGROWTH = 10%) " & _
" LOG ON " & _
"(NAME = " & m_date & "_log,
" & _
" FILENAME = 'D:\Program
Files\Microsoft SQL Server\MSSQL\Da ta\" & m_date & ".ldf', " & _
" SIZE = 1MB, " & _
" MAXSIZE = 5MB, " & _
" FILEGROWTH = 10%) ", conn)

so i wonder m i doing anything wrong???
Any help would be appreciated.

many thanks.

Nov 21 '05 #2
Jon
Thankyou Robert, so i just make "Initial Catalog=master" ?

and could you mind explain more a bit how to grant the user permission in
code?

many thanks in advance.

"Robert Porter" wrote:
To start with, the Initial Catalog can't point to a database that does
not yet exist. Use "master".

Secondly, once you create the database you will have to grant the user
permissions to access the database before you can then log into it.

Hope this helps....

Bob

Jon wrote:
Hi,

I have tried to create a new DB on the SQL Server but unsucessful..
I have looked at the microsoft "How to create SQL Database in vb.net", but
it doesn't seems to solve my problem.

below is the connection string that i used to create, but i get error saying
login has fails. I am sure the login works because i can read out data from
the SQL server no problem...

Dim conn As SqlConnection = New SqlConnection(" Initial Catalog= NewDB;" & _
"Data Source=SERVER-MACHINE;" & _
"UID=abcde; " & _
"PWD=abcde; "

Dim cmd0 As New SqlClient.SqlCo mmand("CREATE DATABASE ON PRIMARY " & _
"(NAME = NewDB, " & _
" FILENAME = 'D:\Program
Files\Microsoft SQL Server\MSSQL\Da ta\" & m_date & ".mdf', " & _
" SIZE = 2MB, " & _
" MAXSIZE = 10MB, " & _
" FILEGROWTH = 10%) " & _
" LOG ON " & _
"(NAME = " & m_date & "_log,
" & _
" FILENAME = 'D:\Program
Files\Microsoft SQL Server\MSSQL\Da ta\" & m_date & ".ldf', " & _
" SIZE = 1MB, " & _
" MAXSIZE = 5MB, " & _
" FILEGROWTH = 10%) ", conn)

so i wonder m i doing anything wrong???
Any help would be appreciated.

many thanks.

Nov 21 '05 #3
In message <A0************ *************** *******@microso ft.com>, Jon
<Jo*@discussion s.microsoft.com > writes
Hi,

I have tried to create a new DB on the SQL Server but unsucessful..
I have looked at the microsoft "How to create SQL Database in vb.net", but
it doesn't seems to solve my problem.

below is the connection string that i used to create, but i get error saying
login has fails. I am sure the login works because i can read out data from
the SQL server no problem...

Dim conn As SqlConnection = New SqlConnection(" Initial Catalog= NewDB;" & _
"Data Source=SERVER-MACHINE;" & _
"UID=abcde; " & _
"PWD=abcde; "

Dim cmd0 As New SqlClient.SqlCo mmand("CREATE DATABASE ON PRIMARY " & _
"(NAME = NewDB, " & _
" FILENAME = 'D:\Program
Files\Microsof t SQL Server\MSSQL\Da ta\" & m_date & ".mdf', " & _
" SIZE = 2MB, " & _
" MAXSIZE = 10MB, " & _
" FILEGROWTH = 10%) " & _
" LOG ON " & _
"(NAME = " & m_date & "_log,
" & _
" FILENAME = 'D:\Program
Files\Microsof t SQL Server\MSSQL\Da ta\" & m_date & ".ldf', " & _
" SIZE = 1MB, " & _
" MAXSIZE = 5MB, " & _
" FILEGROWTH = 10%) ", conn)

so i wonder m i doing anything wrong???
Any help would be appreciated.

many thanks.


Check BOL for the CREATE DATABASE command because yours is NOT correct.
For Example:

CREATE DATABASE [MyNewDB] ON (NAME = N'MyNewDB_Data' , FILENAME =
N'C:\Program Files\Microsoft SQL Server\MSSQL\da ta\MyNewDB_Data .MDF' ,
SIZE = 4, FILEGROWTH = 10%) LOG ON (NAME = N'MyNewDB_Log', FILENAME =
N'C:\Program Files\Microsoft SQL Server\MSSQL\da ta\MyNewDB_Log. LDF' ,
SIZE = 1, FILEGROWTH = 10%) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS

--
Andrew D. Newbould E-Mail: ne********@NOSP AMzadsoft.com

ZAD Software Systems Web : www.zadsoft.com
Nov 21 '05 #4

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

Similar topics

9
2305
by: Marc Miller | last post by:
Hi all, I have 2 dev. machines, the 1st is Win 2000 with .NET 7.0 and the 2nd is XP Pro with .NET 2003. My Web Server is Win 2000 Server with IIS 5.0. I can create a new project on my test server from the 1st machine, but I receive an 'HTTP/1.1 500 Internal Server error" from my Web Server. My userid/password are the same on all 3 machines.
22
1559
by: dw | last post by:
Please help some desperate developers!! We need to create an ASP.NET project via VS.NET 2003 on a networked Win 2003 server that we use for testing, but it keeps generating an error: "The Web server reported the following error when attempting to create or open the Web project located at the following URL:..... HTTP/1.1 500 Internal Server Error." People have said Frontpage Server Extensions (FPSE) have to be on that server; however,...
4
1872
by: jaredea | last post by:
I have the following setup: SBS 2003 Server Windows 2003 Enterprise Server (setup as an Application Server) Windows XP Pro Desktop Both the Application server and desktop have Visual Studio 2003 on them as well as the .NET Framework 1.1 I started to use .NET on the desktop to test things out...then i setup
10
8822
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung other things, can create views based on existing tables and a table of column name equivalents. If I accidently introduce a column name equivalent that is the same as another column, I end up with a CREATE VIEW SQL statement that is in error, if...
3
4328
by: fyi85 | last post by:
I am trying to create a server on the same machine running the same instance. This is v8.1.5 on Windows 2003 Server. The instance is set to FEDERATED=YES The server will be created for database TEST The TEST database will be referenced from database master. There is nobody using the databases and there are no active connections. I log on to the database master from CLP and do
3
5997
by: zgh1970 | last post by:
Hi, All, We have a database on db2 udb aix. The database has federated server to db2 mainframe. Now We have already catalog database of db2/400 on the db2 UDB aix server. I tried to create new federation server for db2as/400. It seam has problem. 1. can the db2 mainframe and db/400 have the same wrapper? Our existing db2 mainframe uses the wrapper with library libdb2drda.a This wrapper is used by db2 mainframe
4
6916
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in path" The value "C:\Temp.txt" is the first value in the array - as it works
4
2292
by: John Straumann | last post by:
Hello all: Most of my development for websites has been on test VPC images where VS is installed on the server image. I now have a setup where I have a test server joined to my domain, and a development PC also joined to the domain. On the server I created a new website on port 99 called "dev", and then on the development PC I tried to create a new http website using http://testserver:99/testwebsite, however I get an error message...
10
2602
by: AAaron123 | last post by:
I want to create a database with one table on the host. I can't user SQL Server Management Studio to do it so I guess I have to do it programmatically. I have in mind that in the session start (or maybe application start would be better) I'd check to see it the database exists and if not create it. The problem is that I have no idea how to do that.
0
10168
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...
0
10009
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9838
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
8835
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...
0
6651
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
5279
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3929
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
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.