Results 1 to 11 of 11

Thread: Why Do I Get This Error???

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Why Do I Get This Error???

    Hi Peeps,

    I have the following code:-

    Code:
            sSQL = "SELECT * FROM FILESTRUCTURE"
            oleDAFiles = New OleDb.OleDbDataAdapter
            oleDAFiles.SelectCommand = New OleDb.OleDbCommand(sSQL, oleDCData)
            oleDSFiles = New DataSet
            oleDAFiles.Fill(oleDSFiles, "FILESTRUCTURE")
    
            For iRowCount = 0 To oleDSFiles.Tables(0).Rows.Count - 1
                oleDSFiles.Tables(0).Rows(iRowCount).Delete()
                oleCBFiles = New OleDb.OleDbCommandBuilder(oleDAFiles)
                oleDAFiles.Update(oleDSFiles, "FILESTRUCTURE")
            Next
    On the update I get a syntax error and do not no why?????

    Thanks for any help,

    Jiggy!

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Re: Why Do I Get This Error???

    Sorry the syntax error is:-

    Code:
    "Syntax error (missing operator) in query expression '((REFNO = ?) AND ((? = 1 AND PATH IS NULL) OR (PATH = ?)) AND ((? = 1 AND FTPPATH IS NULL) OR (FTPPATH = ?)) AND ((? = 1 AND FILENAME IS NULL) OR (FILENAME = ?)) AND ((? = 1 AND MODIFIEDDATETIME IS NULL) OR (MODIFIEDDATETIME = ?)) AND ((? = 1 AND TRANSFER'."

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Why Do I Get This Error???

    What is the value of oleDCData?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Re: Why Do I Get This Error???

    Code:
        Public oleDCData As OleDb.OleDbConnection

  5. #5
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Why Do I Get This Error???

    Show me the connection string...

    Also if you can include the complete code in that sub, I will go through it in one go..
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Re: Why Do I Get This Error???

    Thank u for your help; here is my code:-

    Code:
      Private Sub CreateNewDatabase(ByVal sPath As String)
    
            Dim oleDAFiles As OleDbDataAdapter
            Dim oleDSFiles As DataSet
            Dim oleDRFiles As DataRow
            Dim oleCBFiles As OleDbCommandBuilder
    
            Dim sFileStructure As String
            Dim iLoop As Int16
            Dim sSQL As String
    
            sSQL = "SELECT * FROM FILESTRUCTURE"
            oleDAFiles = New OleDb.OleDbDataAdapter
            oleDAFiles.SelectCommand = New OleDb.OleDbCommand(sSQL, oleDCData)
            oleDSFiles = New DataSet
            oleDAFiles.Fill(oleDSFiles, "FILESTRUCTURE")
    
            iFileCount = -1
            sFileStructure = Dir(sPath & "\*.*", FileAttribute.Directory)
    
            While sFileStructure <> ""
    
                iFileCount = iFileCount + 1
                If sFileStructure <> "" And sFileStructure <> "." And sFileStructure <> ".." Then
                    If (GetAttr(sPath & sFileStructure) And vbDirectory) = FileAttribute.Directory Then
                        iArrayPosition = iArrayPosition + 1
                        iFilePosition(iArrayPosition) = iFileCount
    
                        Call CreateNewDatabase(sPath & sFileStructure)
                        sFileStructure = Dir(sPath & "\*.*", FileAttribute.Directory)
                        iFileCount = 0
                        For iLoop = 0 To iFilePosition(iArrayPosition) - 1
                            sFileStructure = Dir()
                            iFileCount = iFileCount + 1
                        Next
                        iArrayPosition = iArrayPosition - 1
                    Else
                        If UCase$(sFileStructure) <> "FTPSERVER.LDB" Then
                            oleDRFiles = oleDSFiles.Tables(0).NewRow
                            oleDRFiles("PATH") = "m:" & sPath.ToString.Substring(2, Len(sPath) - 2)
                            oleDRFiles("FTPPATH") = Mid$(sChangeSlashes(oleDRFiles("PATH")), 3, Len(oleDRFiles("PATH")) - 2)
                            oleDRFiles("FILENAME") = sFileStructure
                            oleDRFiles("MODIFIEDDATETIME") = FileDateTime(sPath & "\" & sFileStructure)
                            oleDSFiles.Tables(0).Rows.Add(oleDRFiles)
    
                            oleCBFiles = New OleDb.OleDbCommandBuilder(oleDAFiles)
                            oleDAFiles.Update(oleDSFiles, "FILESTRUCTURE")
                        End If
                    End If
                End If
                sFileStructure = Dir()
    
            End While
    
        End Sub

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Why Do I Get This Error???

    What is the value of sPath at the time of the error?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Why Do I Get This Error???

    I think you might be chasing red herrings koolsid. The error message says that there's a syntax error in the SQL code. The most common cause of that is a query that uses a wildcard to return one or more columns whose names are reserved words or contain illegal characters. The way to fix it is to either change your column names or else escape the culprits in the query, e.g. instead of this:
    SQL Code:
    1. SELECT * FROM MyTable
    you do this:
    SQL Code:
    1. SELECT [Column1], [Column2] FROM MyTable
    The command builder should then follow your lead and the syntax error goes away.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Why Do I Get This Error???

    I think you might be chasing red herrings koolsid.
    Possibly Jm

    The error also mention Path error so I wanted to start off from the very start and cover every nook and corner of the code since I cannot test it.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Why Do I Get This Error???

    Quote Originally Posted by koolsid View Post
    The error also mention Path error
    That would be a PATH column in the database table.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Why Do I Get This Error???

    Quote Originally Posted by jmcilhinney View Post
    That would be a PATH column in the database table.
    Ah! In that case I was actually chasing red herrings
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

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



Click Here to Expand Forum to Full Width