Adodc cmdtext issue


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Adodc cmdtext issue

  1. #1
    Join Date
    Oct 2005
    Posts
    133

    Adodc cmdtext issue

    Hi People

    i am having a problem with my recordsource below it says invalid use of property and highlights Text18

    i need to pull data out of my database table (Access 2003) and only show the CDB Numbers that reside between the two dates that get selected during runtime please can you have a look below

    the field it needs to look in is called Visit Date but it can be changed

    Adodc3.CommandType = adCmdText
    Adodc3.RecordSource "Select * From Reports where [Visit Date] LIKE '" & Text17 & "' and > '" & Text18 & "'"
    Adodc3.Refresh
    DataList1.RowSource = Adodc3
    DataList1.DataSource = Adodc3
    DataList1.DataField = "NWC CDB"
    DataList1.ListField = "NWC CDB"
    Adodc3.Refresh
    DataList1.Refresh

    where text17 = start date and
    text18 = end date

    many thanks in advance
    Rob

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Looks like you're missing an equals sign (should be RecordSource = "Select ..."), and I think your SQL should look like this:

    "Select * From Reports where [Visit Date] LIKE '" & Text17 & "' and [Visit Date] > '" & Text18 & "'"

    Finally, be aware that the above SQL will fail if Text17 or Text18 contain an apostrophe.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Oct 2005
    Posts
    133

    thanks Phil

    thanks Phil

    do you have any idea as to why it tells me invalid use of property where as

    DataList1.RowSource = Adodc3 is concerned
    DataList1.DataSource = Adodc3
    DataList1.DataField = "NWC CDB"
    DataList1.ListField = "NWC CDB"


    many thanks in advance
    Rob

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Sorry, no idea.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Oct 2005
    Posts
    133

    still a bit baffled

    HI all

    Adodc3.RecordSource = "Select * From Reports where [Visit Date] LIKE '" & Text17 & "' and [Visit Date] > '" & Text18 & "' where [Report Type] Like '" & Text47 & "'"

    is there any problems that you can see within this above search string

    text17 = Start date
    text18 = End Date
    Text47 = What needs to be looked for between those two dates

    it just gives me the rror as follows
    Syntax error (missing operator) in query expression

    any help is appreciated thanks
    Rob

  6. #6
    Join Date
    Feb 2006
    Posts
    133
    "Select * From Reports where [Visit Date] LIKE '" & Text17 & "' and
    [Visit Date] > '" & Text18 & "' where [Report Type] Like '" & Text47 & "'"
    First remark: Only use 1 where, this is not a correct SQL syntax.
    Second remark: I doubt if you want to use Like, like is normally used together with wildcards, if you want to search a specified value simple use =.

    This should be the outcome then:

    Code:
    "Select * From Reports where [Visit Date]='" & Text17 & "' and 
    [Visit Date] > '" & Text18 & "' and [Report Type]='" & Text47 & "'"
    If you search a text you use ' number -> nothing, date -> #. The field of the database must be a datafield ofcourse + you have to transfer your date textbox-value to date.

    I'll post back to you when I've made an example
    Benjamin

  7. #7
    Join Date
    Oct 2005
    Posts
    133

    thanks Mate

    i am trying to create a search string but none of them seem to be working for me i have now tried to use the string as a recordset for an ADODB connection but it does not like it either

    i feel like pulling my hair out lol

    but i keep trying

    Thanks
    Benjamin

Similar Threads

  1. VB6: ADODC design time vs run time database
    By Tim Johnson in forum VB Classic
    Replies: 4
    Last Post: 09-12-2002, 10:27 AM
  2. They created J#, why couldn't they do VB#?
    By Thomas Eyde in forum .NET
    Replies: 290
    Last Post: 12-22-2001, 03:13 PM
  3. Replies: 0
    Last Post: 09-19-2001, 07:48 AM
  4. ADODC Initialize Connection
    By Greg Cantlon in forum VB Classic
    Replies: 2
    Last Post: 01-27-2001, 02:10 AM
  5. ADODC Initialize Connection
    By Greg Cantlon in forum VB Classic
    Replies: 0
    Last Post: 01-25-2001, 07:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center