Creating Database, User Name and User ID

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 52
Reputation: pardeep3dec is an unknown quantity at this point 
Solved Threads: 1
pardeep3dec pardeep3dec is offline Offline
Junior Poster in Training

Creating Database, User Name and User ID

 
0
  #1
Oct 18th, 2008
Hi friends,
Please tell me how can i create database and user id through below code
i am gotting problem of user login failed. I don't know how can i create database,user through vb.net


Dim conn As New SqlConnection("Server=localhost;user id=;database =;")
Dim comm As New SqlCommand
comm.Connection = conn
comm.CommandType = CommandType.Text
Dim sql As String
sql = "CREATE DATABASE testDB"
comm.CommandText = sql
conn.Open()
comm.ExecuteNonQuery()
conn.Close()


Please help.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Creating Database, User Name and User ID

 
0
  #2
Oct 18th, 2008
The database connection string should be like this

  1. Dim conn As New SqlConnection("Data Source=SERVER_NAME;Initial Catalog=DATABASE;uid=USERNAME;pwd=PASSWORD;")


If in your code you will be creating a database in SQL then you will have to connect to another database (in the connection string) first.
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC