Re: how to create database



This code isnt working. My problem is in opening a connection to the
database. If I try to open it with oledbconnection::open, it gives me an
error like 'Could not find file c:\Users\kiki\Documents\Visual Studio
2005'\Projects\logbook\logbook\localhost'.
Any solution?

"Erland Sommarskog" wrote:

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

  • Re: My Book is Incomplete Regarding SQL Commands ;-(
    ... Hitchhiker's Guide to Visual Studio and SQL Server ... Create a Connection object and pass in a ConnectionString to ... manage the database table you reference. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: (Newbie)Application Roles
    ... level: the database itself. ... SQL Server accommodates these needs through the use of application ... the user's connection through a specific application. ... the connection permanently loses all permissions applied to ...
    (microsoft.public.sqlserver.security)
  • Re: Help! Set up Windows Group to access application
    ... The connection string for a trusted connection is: ... --add login as database user ... SQL Server MVP ... If you have troubles with finding your ways in Crystal Reports, ...
    (microsoft.public.sqlserver.security)
  • Re: My Book is Incomplete Regarding SQL Commands ;-(
    ... Visual Studio but not to VS 2003. ... Create a Connection object and pass in a ConnectionString to address ... manage the database table you reference. ... Yep, my latest book can help too, but mostly if you're targeting SQL Server ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Logging in in background
    ... wold take all kinds of modifictions as I'd need to be checking that each SQL ... my database and all have connection strings associated with them. ... I suspect that there is also an issue on the SQL Server side as I keep ...
    (microsoft.public.access.modulesdaovba)