-
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
-
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
-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks