Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how can i use Prepared statement in SQL SERVER

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-18 : 11:57:08
Rickey Leung writes "when i use prepared statement in SQL Server 2000, the problem will be addressed in "LIKE" operator.
pstmt = con.prepareStatement("select * from userinfo where userName like ?");
pstmt.setString(1,"'rickey%'");
rs = pstmt.executeQuery() ;
while (rs.next()){
......
......
it doesn't works! but if i copy the whole string"select * from userinfo where userName like 'rickey%'" in SQL Server query analyzer, it can select out the result. why? should I use another character instead of "?" ?
please help me....."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-18 : 12:16:05
What language are you programming in? Which data access layer are you using? I'm not familiar with ExecuteQuery or SetString methods, they're not part of ADO. Without more info it'll be difficult to troubleshoot this for you.

Go to Top of Page
   

- Advertisement -