SQL Statement What does it mean? 
Author Message
 SQL Statement What does it mean?

Can someone PLEASE tell me what = """ means?
And what txtClient & """" Means?

I am trying to figure out what this is actually trying to
do, what the """ is representing! THANKS for any help!

Set rsPORTFOLIO = db.OpenRecordset("select * from
[tblForeignCurrencyTemp] " & "where [BILL_CLIENT] = """ &
txtClient & """", dbOpenDynaset)
rsPORTFOLIO.MoveFirst



Sat, 13 Aug 2005 02:22:06 GMT  
 SQL Statement What does it mean?
It might be easier if I try to explain in the whole context of the
statement:

Set rsPORTFOLIO = db.OpenRecordset("select * from
[tblForeignCurrencyTemp] " & "where [BILL_CLIENT] = """ &
txtClient & """", dbOpenDynaset)

The OpenRecordset method expect the first argument to be either a QueryName
or a JET SQL String which is your case.  Now in your case, take the Value of
txtClient as "ABC" for example, you want the resultant SQL String to be:

SELECT * FROM [tblForeignCurrencyTemp]
WHERE [BILL_CLIENT] = "ABC"

The problem here is that you need the DoubleQuotes in the resultant SQL
String and you ALSO use the DoubleQuotes in the String concatenation of the
different String components.  The way to put a DoubleQuote in a
DoubleQuote-delimited String is to put TWO DoubleQuotes to represent a
single DoubleQuote.  Thus, in your case:

"WHERE [BILL_CLIENT] = """

The last DoubleQuote is the String delimiter that goes with the DoubleQuote
before WHERE and the 2 DoubleQuotes after = gives you ONE DoubleQuote in the
resultant String, i.e. the  DoubleQuote before ABC.

Also, for you last component of the String concatenation:

""""

The first and last DoubleQuote are the String delimiters that are used in
the concatenation and the 2 DoubleQuotes inside gives you ONE DoubleQuote in
the resultant String, i.e. the DoubleQuote after ABC.

Since JET Database Engine can also use SingleQuotes, you can simplify this
somewhat.  Also, you can use the Debug.Print in your code to see the
resultant SQL String which is passed to JET for processing using something
like:

...
Dim strSQL As String

strSQL = "SELECT * FROM [tblForeignCurrencyTemp] " & _
    "WHERE [BILL_CLIENT] = """ & txtClient & """"

Debug.Print strSQL

Set rsPORTFOLIO = db.OpenRecordset(strSQL, dbOpenDynaset)
...

and you can actually see the resultant SQL String which is passed to JET.

If you want to use SingleQuotes you can try:

strSQL = "SELECT * FROM [tblForeignCurrencyTemp] " & _
    "WHERE [BILL_CLIENT] = '" & txtClient & "'"

(after the = is SingleQuote + DoubleQuote and
the end is DoubleQuote + SingleQuote + DoubleQuote)

but you have to watch out for apostrophes in names.

Alternatively, you can use the Chr$(34) to get the DoubleQuote in the
resultant String like:

strSQL = "SELECT * FROM [tblForeignCurrencyTemp] " & _
    "WHERE [BILL_CLIENT] = " & Chr$(34) & txtClient & Chr$(34)

--
HTH
Van T. Dinh
MVP (Access)


Quote:
> Can someone PLEASE tell me what = """ means?
> And what txtClient & """" Means?

> I am trying to figure out what this is actually trying to
> do, what the """ is representing! THANKS for any help!

> Set rsPORTFOLIO = db.OpenRecordset("select * from
> [tblForeignCurrencyTemp] " & "where [BILL_CLIENT] = """ &
> txtClient & """", dbOpenDynaset)
> rsPORTFOLIO.MoveFirst



Sat, 13 Aug 2005 04:32:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SQL statement not doing its job

2. doing updating from grid to sql server with stored procedure sql 2000

3. running sql code record by record instead of statement by statement

4. Assistance doing select statement

5. Dynamic SQL Statement With SQL 6.5

6. SQL -- Needing a Hint with SQL statements.

7. SQL statement won't consistently pass from VB to SQL

8. OCX for editing SQL-Statements (SQL-Server)

9. SQL query: from SELECT statement to stored procedure with dynamic PL/SQL

10. SQL statement updateable in Acces but not SQL Server

11. Problem on SQL-Update Statement with a Data-Control in VB 5 and SQL Server 7.0

12. Write One SQL statement execute in Oracle and SQL Server

 

 
Powered by phpBB® Forum Software