Well I finally got it. I am posting this hoping it will help someone else as well. Here is what I did.
1. Created a database using the DTO objects. Make sure a reference to Pervasive Distributed Tuning Library 1.0 is made.
Dim result As dtoResult
Dim m_dtoDatabase As New DtoDatabase
Dim m_dtoTable As New DtoTable
With m_dtoDatabase
.DataPath = Trim(txtLocation.Text)
.DdfPath = Trim(txtLocation.Text)
.Name = txtName.Text
.Flags = dtoDbFlagCreateDDF
End With
result = m_dtoSession.Databases.add(m_dtoDatabase)
If result = Dto_Success Then
MsgBox "Database added correctly"
Command2.Enabled = False
Else
MsgBox "Error adding database. Error Code: " & result
End If
Set m_dtoDatabase = Nothing
2. Created an ODBC system DSN link to the database, also with the DTO.
Dim lResult As dtoResult
' we're already logged in. we can just start creating the DSN
Dim mDtoDSN As New DtoDSN
With mDtoDSN
.DBName = txtName.Text
.Description = "test"
.Name = "MyDSN"
.OpenMode = 0
End With
lResult = m_dtoSession.DSNs.add(mDtoDSN)
If lResult <> Dto_Success Then
MsgBox "Error adding DSN. Error code: " & CStr(lResult), vbCritical, "Error"
Else
MsgBox "DSN Added.", vbInformation, "DSN added."
End If
3. Created and ADO connection using the newly created DSN and added tables and indexes via Create SQL statements. This allowed me to use all available data types and add defaults values to any fields that needed them. The SQL statements needed for the entire database were stored in a resource file and called with the for loop.
Dim conn As ADODB.Connection
Dim i As Integer
Set conn = New ADODB.Connection
With conn
.ConnectionString = "DSN=MyDSN"
.CursorLocation = adUseServer
.Open
End With
For i = 1 To 17
conn.Execute LoadResString(i)
Next l_intCount
conn.Close
Set conn = Nothing
Here is an example of the SQL statement to create a Customer table and an index to ensure that the Customer Number remains unique and cannot be changed once in the database.
CREATE TABLE Customer(CustomerID IDENTITY DEFAULT '0' NOT NULL,CustomerNumber VARCHAR(20) NOT NULL,cuShortName VARCHAR(20),cuFullName VARCHAR(60),cuAddress1 VARCHAR(60),cuAddress2 VARCHAR(60),cuCity VARCHAR(30),cuProvState VARCHAR(30),cuPCZip VARCHAR(20),cuCountry VARCHAR(30),cuPhone VARCHAR(30),cuFax VARCHAR(30),cuContact VARCHAR(60),cuEmail1 VARCHAR(50),cuEmail2 VARCHAR(50),cuGroupCode VARCHAR(15),cuAccountSet VARCHAR(15),cuPriceList VARCHAR(15),cuTermsCode VARCHAR(15),cuTaxGroup VARCHAR(15),cuCustType TINYINT DEFAULT '0' NOT NULL,Exported TINYINT DEFAULT '0' NOT NULL)
CREATE UNIQUE NOT MODIFIABLE INDEX CN_CustomerNumber ON Customer(CustomerNumber ASC)
Thanks to mirtheil for all your help and advice. Thanks and Good Luck!
zemp