Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2006, 04:28 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default can anyone help me please

i'm having this error in my program
it says
"invalid sql statement:expected DELETE,INSERT,PROCEDURE,SELECT,OR UPDATE"
whenever i click the minus sign in the tree this error show up
here is the coding
hope anyone can help me out

Private Sub Form_Load()
Set adoConnection = New ADODB.Connection
adoConnection.Open "Provider = Microsoft.Jet.OLEDB.4.0; Persist Security Info = False;Data Source = " & App.Path & "\employee.mdb"
If tvDatabase.Nodes.Count > 0 Then
  tvDatabase.Nodes(1).Expanded = False
End If
tvDatabase.Nodes.Clear
tvDatabase.Sorted = True
Set mNode = tvDatabase.Nodes.Add()
mNode.Text = "Tables"
mNode.Tag = adoConnection.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))


Set adoRsFields = New ADODB.Recordset
Set adoRsFields = adoConnection.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))

mNode.Image = "Folder"
tvDatabase.LabelEdit = tvwManual
Do Until adoRsFields.EOF

    If Left(adoRsFields!Table_Name, 4) <> "MSys" Then
        Set mNode = tvDatabase.Nodes.Add(1, tvwChild, , adoRsFields!Table_Name, "Table")
        mNode.Tag = "Tables"
        TableIndex = mNode.Index
        Set adoRsField = adoConnection.OpenSchema(adSchemaProviderTypes)
        Do Until adoRsField.EOF
            'Debug.Print "Data Type: " & adoRsFields!TYPE_NAME & vbTab _
            '& "Column Size: " & adoRsFields!COLUMN_SIZE
            Set mNode = tvDatabase.Nodes.Add(TableIndex, tvwChild)
            mNode.Text = adoRsField!TYPE_NAME & Space(25) & adoRsField!COLUMN_SIZE
            adoRsField.MoveNext

        Loop
    End If
mNode.Tag = "Fields"
FieldsIndex = mNode.Index
adoRsFields.MoveNext
Loop
DoEvents
PBar(0).Visible = False
For i = 1 To tvDatabase.Nodes.Count - 1
tvDatabase.Nodes(i).Sorted = True
Next i
Screen.MousePointer = 0
tvDatabase.Nodes(1).Expanded = True
'tvDatabase.SetFocus
SendKeys "{HOME}", True
Exit Sub



adoRsFields.Close
Set adoRsFields = Nothing
adoConnection.Close
Set adoConnection = Nothing



End Sub
Private Sub tvDatabase_NodeClick(ByVal Node As ComctlLib.Node)
Screen.MousePointer = 13
On Error Resume Next
Set mNode = Node
If Node.Tag = "Tables" Then

  TableName = Node.Text
  Screen.MousePointer = 0

        Adodc1.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Persist Security Info = False;Data Source = " & App.Path & "\employee.mdb"
        Adodc1.RecordSource = TableName

        On Error Resume Next
        Adodc1.Refresh
        If InStr(TableName, " ") Then
            Adodc1.RecordSource = "SELECT * FROM " & TableName & Adodc1.Recordset.Fields(0).Name
        End If
        On Error Resume Next
        Adodc1.Refresh
        'DataGrid1.ReBind
        DataGrid1.Caption = "TABLE: " & TableName


End If

End Sub










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.