MSSQL LIKE and IN statements in ADO problem

Michael.Coll-Barth at VerizonWireless.com Michael.Coll-Barth at VerizonWireless.com
Wed Jan 18 18:24:53 CET 2006



huh?

This seems to work just fine for me...


>>> name = '%raj%'
>>> test = "SELECT * FROM tb_name WHERE firstname LIKE '%s'" % name
>>> print test
SELECT * FROM tb_name WHERE firstname LIKE '%raj%'




-----Original Message-----
From:
python-list-bounces+michael.coll-barth=verizonwireless.com at python.org
[mailto:python-list-bounces+michael.coll-barth=verizonwireless.com at pytho
n.org]On Behalf Of gregarican
Sent: Wednesday, January 18, 2006 11:34 AM
To: python-list at python.org
Subject: Re: MSSQL LIKE and IN statements in ADO problem


Can't you get rid of the Create Parameter part and directly pass along
the value you are looking for? Something like...

name = 'raj'
cmd.CommandText= \
        "SELECT * FROM tb_name WHERE firstname LIKE %%%s" % name

This way the value of the name variable gets passed along when the
CommandText method is invoked. BTW, this looks too painfully much like
Visual Basic than Python :-) Just kidding (kind of)

-- 
http://mail.python.org/mailman/listinfo/python-list


The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.




More information about the Python-list mailing list