Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    72

    Unanswered: create table and fields

    I have maked this little code but dont know the way to insertt new table and fileds in database DATABASE01...


    Private Sub Command1_Click()

    Dim objConn As ADODB.Connection
    Set objConn = New ADODB.Connection
    objConn.ConnectionString = "driver={SQL Server};server=DVD377-14D9E48C\SQLEXPRESS;uid=;pwd=;database=master"
    objConn.Open
    objConn.Execute "CREATE DATABASE DATABASE01"

    ''''''''''''''''''
    '"CREATE table Mytable"
    ''''''''''''''''''

    ''''''''''''''''''
    '"CREATE filed1" in text format
    '"CREATE filed2" in text format
    '"CREATE filed3" in text format
    '"CREATE filed4" in date format(DD/MM/YYYY)

    ''''''''''''''''''

    objConn.Close

    End Sub

  2. #2
    Join Date
    Feb 2003
    Location
    India
    Posts
    216
    u should not be creating a database from a front end code. however, to create tables open another connection object by another connection string using the newly created database name. and then use the "Create Table" SQL. Check BOL for syntax etc.

Posting Permissions

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