Results 1 to 7 of 7

Thread: [RESOLVED] Does Adapter.fill have a query length restriction?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    200

    Resolved [RESOLVED] Does Adapter.fill have a query length restriction?

    Basically!

    I have a database with around 100 columns and when i go:

    Code:
    Me.Validate()
    Adapter.Update(Table)
    It fails after i edit the table, giving me an error:

    Syntax error (missing operator) in query expression '((ID = ?) AND ((? = 1 AND Record IS NULL) OR (Record = ?)) AND ((? = 1 AND Details_FileCreated IS NULL) OR (Details_FileCreated = ?)) AND ((? = 1 AND Details_Particulars IS NULL) OR (Details_Particulars = ?)) AND ((? = 1 AND Details_Date IS NULL) OR (Deta'.

    The code works fine with a smaller database, so i was just wondering the problem is that the database is too big and the adapter isn't able to handle such a long query.

    I was just wondering if anyone knows what kind of limits there are?

    Thanks,
    Last edited by Zapper; Apr 10th, 2010 at 04:20 AM.

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

    Re: Does Adapter.fill have a query length restriction?

    What happens if you omit the Record column? Does it work then?
    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    200

    Re: Does Adapter.fill have a query length restriction?

    Hey jmcilhinney,

    I did some more testing and research and i found this:

    http://blogs.msdn.com/spike/archive/...ng-access.aspx

    Too many "Ands".Im planning to just go create multiple tables. Can you think of a better way to work around it?

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

    Re: Does Adapter.fill have a query length restriction?

    One possibility is removing the optimistic concurrency built into that query. Only do that if you don't need it though. That would remove vertually the entire WHERE clause.
    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

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    200

    Re: Does Adapter.fill have a query length restriction?

    I just googled "optimistic concurrency" and from what i understand, it would not affect me if i were to remove optimistic concurrency as, for my purpose, only one person uses the database at one time.

    So may i ask how?

    i have a datagridview class, heres part of the code for it:

    Code:
    Public Class DatagridClass
        '... Variables goes here (omitted) ...
    
        Public Sub New(ByVal _FilePath As String, ByVal _TableName As String, ByRef _DataGrid As DataGridView)
    
            Connection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _FilePath)
            Sql = New OleDbCommand
            Adapter = New OleDbDataAdapter("SELECT * FROM " & TableName, Connection)
            Builder = New OleDbCommandBuilder(Adapter)
            Table = New DataTable
    
            Adapter.Fill(Table)
            DataGrid.DataSource = Table
    
        End Sub
    
        Public Sub Save()
             Parent.Validate()
            Adapter.Update(Table)
        End Sub
    Thanks,

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

    Re: Does Adapter.fill have a query length restriction?

    I believe that you would set the ConflictOption property of your CommandBuilder to OverwriteChanges. Note that you should be setting the MissingSchemaAction property of your DataAdapter to AddWithKey, so that your DataTable contains primary key information that your CommandBuilder can use and therefore avoid using the other columns to identify which record to update/delete.
    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

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    200

    Re: Does Adapter.fill have a query length restriction?

    Thanks so much, as again, jmcilhinney.

    Builder.ConflictOption = ConflictOption.OverwriteChanges <- Works like a wiz

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