vb4 AND sql queries 
Author Message
 vb4 AND sql queries

I'm using vb4 and using a data module to handle
most of the record selecting and handling. In a query
that looks like this

"Select * From Clients Where ClientName = ' " + variable + " ';"

problems arise when the string variable contains a -> ' <-
e.g. (with the variable in it looks like this
"Select * From Clients Where ClientName = 'Veteran's Affairs';"

as this corrupts the string, but for the program I need to have
this ability to do comparison like this



Sat, 14 Oct 2000 03:00:00 GMT  
 vb4 AND sql queries

Which database are you connecting to? If you are using Oracle or SQL
server, you can use bind variable to avoid the problem.

Hyong J. Cho

Quote:

> I'm using vb4 and using a data module to handle
> most of the record selecting and handling. In a query
> that looks like this

> "Select * From Clients Where ClientName = ' " + variable + " ';"

> problems arise when the string variable contains a -> ' <-
> e.g. (with the variable in it looks like this
> "Select * From Clients Where ClientName = 'Veteran's Affairs';"

> as this corrupts the string, but for the program I need to have
> this ability to do comparison like this



Sat, 14 Oct 2000 03:00:00 GMT  
 vb4 AND sql queries

Martin,

Quote:
>problems arise when the string variable contains a -> ' <-

enclose the search string in double-quotes:

"Select * From Clients Where ClientName = " & chr(34) &
strYourVariable & chr(34)

This ends up with:

select * From Clients where ClientName = "Veteran's Affairs"

Alternatively, you could parse your input string and change all
occurrences of the ' character to a pair of '' marks.

-- Jim Ferguson, FMS
   http://www.fmsinc.com



Sat, 14 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB4.0 Sql query

2. how can I build 2 queries in 1 query(VB SQL query)

3. Running SQL Query with DBCS in VB4.0 and DAO 2.5

4. Open ended query system using SQL in VB4 32-bit

5. Help please - SQL query in VB4

6. SQL Queries in VB4.0/16

7. SQL queries in VB4

8. Q: VB4 RDO/Access95 How to use LIKE in SQL (or Access 95 queries)

9. SQL Query - MAX, Grouping and Sub query

10. SQL query works, Crystal query doesn't

11. Using Sub Query in Sql Query - Crystal Report 5.0

12. VB Query vs SQL Query Analyzer Speed?

 

 
Powered by phpBB® Forum Software