Results 1 to 3 of 3

Thread: How to create a database in SQL Server from VB

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Posts
    55

    Question


    How can i create a database in SQL server from vb

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Talking

    Hi gorthims

    To create A new database IN VB you have to do it in two sections.

    Firstly if you want to use new devices for the database you need to do the following.

    Set a connection to the server then use the following code

    myconnection.execute "DISK INIT Name = `NewDevice'," & _
    "PhysName = `C:\SQL65\DATA\NewDevice.DAT'," & _
    "VDevNo = 6," & _
    "Size = 2500"

    This Will only work in SQL6.5 And not seven but if you are using 7.0 and I remember correctly, seven automatically creates the devices for you

    Next

    Once the deivices are created or if you want to use existing ones use the follwing code

    myconnection.execute "CREATE DATABASE database_name" & _
    "[ON {DEFAULT | database_device} [= size]" & _
    "[, database_device [= size]]...]" & _
    "[LOG ON log_device [= size]" & _
    "[,log_device[= size]]...]" & _
    "[FOR LOAD]"

    Most of those options speak for themselves but you can look in books-online for further information.

    And there you have it one brand new spanking database sitting on your server.

    Finally you can use the create table statement to yes, youve got it , craete tables for your new database.

    If you need any more help, reply back

    Hope this helps
    Ian

    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2000
    Posts
    55

    Smile

    ThanQ Ianpbaker

    This will help me.

Posting Permissions

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



Click Here to Expand Forum to Full Width