Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Location
    India
    Posts
    1

    Cool Unanswered: Creating SQL Data base

    Hi,

    I want to create SQL Data and default user base using Visual Basic. any body help me to create it


    thanks for your advise

    bye

  2. #2
    Join Date
    Aug 2002
    Posts
    6

    Creating SQL Data base

    if you have a script file
    you can use shell command or winexec api, e.g.

    winexec("osql.exe -S -usa -p -iscriptfile", SW_HIDE)

    about osql' parameters, to see sql server online help

  3. #3
    Join Date
    Dec 2002
    Location
    Czech Republic
    Posts
    249

    Re: Creating SQL Data base

    You can execute script string in ADODB.Command object.

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    The simplest way is:

    Dim cn As ADODB.Connection

    Set cn = New ADODB.Connection
    cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=myserver"
    cn.Execute "create database test"
    cn.Close
    Set cn = Nothing

    You can get more fancy with this. If you will use this more than once I would recommend creating a stored procedure that you would execute. This can also be used if you need to pass parameters like database name, location, size ...

    If you are using vb.net take a look at the following ms article:

    article

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •