GUI Innovations for Innovative Solutions

eVB Sample Code

Private Sub CmdCreate_Click()
  If InStr(LCase(txtDbName.Text), ".sdf") = 0 Then
    txtDbName.Text = txtDbName.Text & ".sdf"
  End If
  If Len(Trim(txtDbName.Text)) = 0 Then
    MsgBox "Please enter a Database Name ", vbInformation, "Db Name"
    txtDbName.SetFocus
    Exit Sub
  End If
  If File_Exists(txtDbName.Text) Then
    MsgBox txtDbName.Text & " already exists!", vbInformation, "Db Name"
    txtDbName.SetFocus
    Exit Sub
  End If
  Dim Ans As Integer
  Dim strSql As String
  Dim adoCat As ADOXCE.Catalog
  Set adoCat = CreateObject("ADOXCE.Catalog.3.1")
  adoCat.Create "Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0; data source=\" & txtDbName.Text
  Set adoCat = Nothing
  Set cn = CreateObject("ADOCE.Connection.3.1")
  Set rs = CreateObject("ADOCE.Recordset.3.1")
  cn.Open "Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0; data source=\" & txtDbName.Text
 
  Screen.MousePointer = 11
  txtProgress.Text = txtProgress.Text & "Creating titleauthor" & vbCrLf

  'Create Table titleauthor
  strSql = "Create Table " & Chr(34) & "titleauthor" & Chr(34) & "("
    strSql = strSql & Chr(34) & "au_id" & Chr(34) & " nvarchar(11) NOT NULL , "
    strSql = strSql & Chr(34) & "title_id" & Chr(34) & " nvarchar(6) NOT NULL , "
    strSql = strSql & Chr(34) & "au_ord" & Chr(34) & " integer , "
    strSql = strSql & Chr(34) & "royaltyper" & Chr(34) & " integer )"
  On Error Resume Next
  cn.Execute (strSql)
  If Err.Number <> 0 Then
    Ans = MsgBox("titleauthor - " & Error_Message(cn) & vbCrLf & "Continue?", vbQuestion + vbYesNo, "SQL Error")
      If Ans <> vbYes Then
        Exit Sub
      End If
  End If
  txtProgress.Text = txtProgress.Text & "Creating stores" & vbCrLf

  'Create Table stores
  strSql = "Create Table " & Chr(34) & "stores" & Chr(34) & "("
    strSql = strSql & Chr(34) & "stor_id" & Chr(34) & " nvarchar(4) NOT NULL , "
    strSql = strSql & Chr(34) & "stor_name" & Chr(34) & " nvarchar(40), "
    strSql = strSql & Chr(34) & "stor_address" & Chr(34) & " nvarchar(40), "
    strSql = strSql & Chr(34) & "city" & Chr(34) & " nvarchar(20), "
    strSql = strSql & Chr(34) & "state" & Chr(34) & " nvarchar(2), "
    strSql = strSql & Chr(34) & "zip" & Chr(34) & " nvarchar(5))"
  On Error Resume Next
  cn.Execute (strSql)