Re: how to create database

Tech-Archive recommends: Speed Up your PC by fixing your registry



empire1986 (empire1986@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
Yeah, I googled it and found nothing. Can you tell me how can I do it with
sql server?

Dim cn As New OleDbConnection, _
strConn As String

AddHandler cn.InfoMessage, AddressOf OledbInfoMessage

' Connection string, change server and database!
strConn = "Provider=SQLNCLI;Integrated Security=SSPI;"
strConn &= "Data Source=(local);Initial Catalog=tempdb"

Try
cn.ConnectionString = strConn
cn.Open()
Catch ex As Exception
Console.Writeline(ex.Message, "Connection failed!")
cn = Nothing
Exit Sub
End Try

Dim cmd As OleDbCommand = cn.CreateCommand()

cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = "CREATE DATABASE nisse"
cmd.ExecuteNonQuery()

Not that I know Access, but I can't imagine that it can be that
different.

Then again, this forum is really about the native OLE DB API, and
not the OleDb .Net Provider. For general questions on ADO .Net,
microsoft.public.dotnet.framework.adonet is a better to ask in.


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • asp.net 2.0 login control
    ... A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.] ... These problems left me stranded for days, then today, on another machine, I hit a different set of problems I kept getting the following "Failed to generate user instance of SQL Server due to a failure in starting the process for the user instance. ... (Basically this is a new option in the connection string that allows you to point out where the ..mdf file resides eliminating the need to create database in some SQL instance.) ... Beware that the windows account of the user that first creates the connection in this databaseless manner, becomes exclusive user for this file and no other windows account will be able to create a connection to this file. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Newbie question on SQL connection
    ... database on my developer machine. ... > to develop databases away from the live SQL server - that way in the ... > domain SQL Server. ... Does your connection string contain a typo? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: .NET and SQL Server on Separate Machines
    ... add this domain account as a valid login to your sql server. ... Everything was running correctly when the database ... > The connection string in our web.config file originally looked like this: ...
    (microsoft.public.sqlserver.connect)
  • Re: .NET and SQL Server on Separate Machines
    ... add this domain account as a valid login to your sql server. ... Everything was running correctly when the database ... > The connection string in our web.config file originally looked like this: ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: MS Access DAO -> ADO.NET Migration
    ... William Vaughn ... Microsoft MVP ... Hitchhiker's Guide to Visual Studio and SQL Server ... My migration app works building a SSCE database file with imported data ...
    (microsoft.public.dotnet.framework.adonet)