CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 1999

    Create Access Database with ADO(X) from VB6

    i want to create an access file from my app with ADO(X).
    i create a sql database with ado using ado.command. but it doesnt run for access db. the code is below.

    ADOXcatalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "c:\newdata.mdb"

    'this string runs properly for mssql server-----
    S = "CREATE TABLE [GR_AnaDepartman] ("
    S = S & " [AnaDepID] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,"
    S = S & " [AnaDepKod] [nvarchar] (8) COLLATE Turkish_CI_AS NOT NULL ,"
    S = S & " [AnaDepAck] [nvarchar] (20) COLLATE Turkish_CI_AS NULL ,"
    S = S & " ("
    S = S & " [AnaDepID]"
    S = S & " ) ON [PRIMARY]"
    S = S & ") ON [PRIMARY]"
    mycmd.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "c:\newdata.mdb"
    mycmd.CommandText = S
    mycmd.Execute S

    i have some pure adox code for creating access db. but i cannot give all properties to my fields.especially Autonumber property.
    just adox codes.....

    ADOXcatalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "c:\newdata.mdb"

    ADOXcatalog.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "c:\newdata.mdb"

    'name table, append fields to table
    ADOXtable.Name = "Employees"
    ADOXtable.Columns.Append "LastName", adVarWChar, 40
    ADOXtable.Columns.Append "ID", adInteger
    ADOXtable.Columns.Append "Department", adVarWChar, 20

    'append tables to database
    ADOXcatalog.Tables.Append ADOXtable

    'internal index on two fields
    ADOXindex.Name = "idxID" 'name of index
    ADOXindex.Columns.Append "ID"
    ADOXindex.PrimaryKey = True

    ADOXtable.Indexes.Append ADOXindex

    can anyone give a sample or clue?or does anyone have a good simple program for creating all codes for existing mdb file?i want to get all codes for creating a mdb file.

    thanx in advance.

  2. #2
    Join Date
    Feb 1999

    Re: Create Access Database with ADO(X) from VB6

    ok. i found a good sample from pscode.
    here is the link:


Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

By using this site, you agree to the Privacy Policy