ADO db runtime creation

hai friends

I am doing a projent in vb & sql server.in which i have to create a database in run time. if anyone knows plz send the code.

bye

Comments

  • : hai friends
    :
    : I am doing a projent in vb & sql server.in which i have to create a database in run time. if anyone knows plz send the code.
    :
    : bye
    :
    I'll get back to you later today.
    [blue]
    C:Dos
    C:Dos Run
    Run Dos Run
    [/blue]

  • [b][red]This message was edited by Moderator at 2004-3-30 9:40:29[/red][/b][hr]
    : : hai friends
    : :
    : : I am doing a projent in vb & sql server.in which i have to create a database in run time. if anyone knows plz send the code.
    : :
    : : bye
    : :
    : I'll get back to you later today.
    : [blue]
    : C:Dos
    : C:Dos Run
    : Run Dos Run
    : [/blue]
    :
    :


    It would be much easier to do it through query anylyzer or enterprise manager but you can execute batches through ADO Command objects the same as you in query anylyzer.
    if you set all of the sql code below into a single string Say strSQL you can then execute it(see below code).

    CREATE DATABASE Test
    ON
    (NAME='TEST_Data',
    FILENAME='C:Program FilesMicrosoft SQL ServerMSSQLdataTest_Data.MDF',
    SIZE=1, FILEGROWTH=10%)
    LOG ON (NAME='Test_Log',
    FILENAME='C:Program FilesMicrosoft SQL ServerMSSQLdataTest_Log.LDF',
    SIZE=1, FILEGROWTH=10%)
    COLLATE SQL_Latin1_General_CP1_CI_AS
    GO
    CREATE TABLE Brand_T (
    BrandID varchar (5) NOT NULL ,
    BrandName varchar (10) NOT NULL
    )
    GO

    CREATE TABLE Colour_T (
    ColourID varchar (5) NOT NULL ,
    Colour varchar (10) NOT NULL
    )
    GO


    [code]
    Set objConn = New ADODB.Connection
    objConn.Open "DSN=testSchema"
    Set objCom = New ADODB.Command
    With objCom
    .ActiveConnection = objConn
    .CommandText = strSQL
    .Execute
    End With
    [/code]
    testSchema is a DSN I have set up(it does not matter what database you are in when you execute the above code)


    Hope it helps.
    [blue]
    C:Dos
    C:Dos Run
    Run Dos Run
    [/blue]



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion