how to pass variable into sql statement on dataenvironment


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: how to pass variable into sql statement on dataenvironment

  1. #1
    mano Guest

    how to pass variable into sql statement on dataenvironment


    How do i pass a variabe such as text1.text under command 's sql statement
    (DataEnvironment--->Connection---command,sql)

    Please help

    Thanks

  2. #2
    Voicescu Guest

    Re: how to pass variable into sql statement on dataenvironment


    "mano" <armanot@adc.metrica.com.my> wrote:
    >
    >How do i pass a variabe such as text1.text under command 's sql statement
    >(DataEnvironment--->Connection---command,sql)
    >
    >Please help
    >
    >Thanks


    Your problem is SQL-grammatical ?You can make like this:

    Dim objConn As New ADODB.Connection
    Dim rstUtente As ADODB.Recordset
    Set rstUtente = New ADODB.Recordset
    Dim strCnn As String

    strCnn = "Provider=SQLOLEDB.1;Password=ISIT;Persist SecurityInfo=True;UserID=ISIT;InitialCatalog=SECURITY;DataSource=SNTDBMS"

    ' open connection
    objConn.Open strCnn

    'your query
    strQuery = " SELECT TIM_STAT FROM ISIT_UTENTI WHERE COD_UTEN = '" & Trim(text1.text)
    & " '"


    With rstUtente
    .LockType = adLockOptimistic
    .CursorLocation = adUseClient
    .CursorType = adOpenKeyset
    .ActiveConnection = objConn
    .Open strQuery , Options:=adCmdText
    End With


  3. #3
    RDJ ... Guest

    Re: how to pass variable into sql statement on dataenvironment


    "mano" <armanot@adc.metrica.com.my> wrote:
    >
    >How do i pass a variabe such as text1.text under command 's sql statement
    >(DataEnvironment--->Connection---command,sql)
    >
    >Please help
    >
    >Thanks


    say text1.text = "mano"...
    strSQL = "select * from questions where author ='" & text1.text & "'"
    objConn.Execute strSQL

  4. #4
    Bob Barnard Guest

    Re: how to pass variable into sql statement on dataenvironment


    "mano" <armanot@adc.metrica.com.my> wrote:
    >
    >How do i pass a variabe such as text1.text under command 's sql statement
    >(DataEnvironment--->Connection---command,sql)
    >
    >Please help
    >
    >Thanks


    Actually, I believe the answer to your question involves sql created through
    a command object
    in the data environment. To do that you code your sql and in the "where"
    clause you will code
    "Where Lastname = ?". Then if you go to the parameters tab of the command,
    you will see
    it listed. Update the parameter information and save. Then in your code
    you use the
    following statement dataenvironment.commandname text1.text. This will open
    and execute the
    command with text1.text being used as a parameter in the where clause replacing

    the ?. Make sure the command is not already open or you will receive an
    error. As you type
    the statement, like any other VB procedure, you will see a list of all your
    parameters.

    Hope this is what you were looking for.

    Bob

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