Results 1 to 6 of 6

Thread: SQL with variables via DataEnvironment

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Location
    the Netherlands
    Posts
    24

    Question SQL with variables via DataEnvironment

    Hi all there,

    Every time I use SQL in cooperation with the DataEnvironment in VB6, I have troubles. Need your help mostly:

    I have created a connection in the DataEnvironment and by the SQL-builder i made the commandtext.

    e.g.

    DataEnvironmentname = DE
    Connectionname = CRMDATABASE
    Commandname = AllCust


    The syntax of the sql =
    SELECT KUNNR, NAME1, STRAS, PSTLZ, ORT01, LAND1, LOEVM FROM ZAN_KNA1 WHERE (NAME1 LIKE '"*" & `m_NAME` & "*"') AND (ORT01 LIKE '"*" & `m_CITY` & "*"') AND (LAND1 LIKE '"*" & [m_COUNTRY] & "*"')

    As you see m_NAME, m_CITY and m_COUNTRY are variables, defined in the code. As you can also see, I use the * in front of
    and behind the variable, so the user can type a few characters and the sql must populate the recordset

    In code i use the next syntax for opening the recordset

    DE.rsAllCust.open and the result is DE.rsAllCust.recordcount = 0

    The problem is everytime, what do i use around the variables:
    is that {} or [] or () or '' or "" or whatever???????

    Help would be appreciated..


    Ger

  2. #2
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    Try % instead of *. (% is used with ado)
    VB 6.0, Access, Sql server, Asp

  3. #3
    Lively Member
    Join Date
    Dec 2001
    Location
    South Africa
    Posts
    88
    Sorry

    SQL like that will never work with DE. If you are trying to create a very simple Data Report. Connect using Code, Connection like

    VB Code:
    1. Dim CNN as New ADODB.Connection

    Then open the Recordset

    VB Code:
    1. Set DataReport.DataSource=Recordset

    Then
    VB Code:
    1. DataReport.Show

    Try this one it will work for you. This is the reason why many run to using Crysteal report and not Datareports.

    If the report is Hierychal, you must stick to DE, I do not have the answer for you.

    I hope you come right.

    Wizard
    SA

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by ralph
    Try % instead of *. (% is used with ado)
    Actually it's an Access/SQL issue, not an ado one... Access uses '*' as it's wildcard, while SQL uses '%'....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Location
    the Netherlands
    Posts
    24
    Thx guys,

    So SQL % and ACCESS * as wildcard

    But when i tried it , the result seemed to be:

    SQL % and ACCESS ? as wildcard

    Where can I find documentation about this ?

    Greetings, Ger

  6. #6
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    quote by techgnome:
    Actually it's an Access/SQL issue, not an ado one... Access uses '*' as it's wildcard, while SQL uses '%'....
    It's also an ado issue, oledb provider dependent (jet4.0 vs odbc driver)
    http://support.microsoft.com/default...NoWebContent=1
    http://support.microsoft.com/default...NoWebContent=1
    VB 6.0, Access, Sql server, Asp

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