Hi Nitin,

I'm mailing this from my netscape webmail-account since my two previous
attempts wasn't successful.
A cable in the Atlantic is broken and could be the reason for my mails not
reaching the list.

Please see my previous posting about where I states "it is important NOT
to use the '' surrounding string arguments when preparing statements."

So,
"Select * from Empdet where Empfname like '*" +"?"+ "*' AND Emplname
like "+"?"+"*' ";

should instead be
"Select * from Empdet where Empfname like ? AND Emplname like ?";

I have removed '' sourrounding string arguments and also removed *.
This statement shall work!

cheers
Stein


Nitin Kulkarni wrote:
>
> Hi,
>     We tried the query you gave us and we are getting the following error.
>
> 'javawebserver: [Microsoft][ODBC Driver Manager] Invalid argument value'.
>
> You had given the example of a static query whereas we are using a dynamic
> query. so we changed the variable and put ? in it's place.
>
> Also % doesn't work with MS Access. so we used * init's place.
>
> we don't know where we are going wrong as we have tried out all possible
> combinations in constructing a dynamic query.
>
> Some of the imp statements in the program are as below:
>
> String bempnamesql = "Select * from Empdet where Empfname like '*" +"?"+
"*'
> AND Emplname like "+"?"+"*' ";
>
> PreparedStatement prepstmt1;
> prepstmt1 = con.prepareStatement(bempnamesql);
>
> prepstmt3.setString(1,ht_empfname);   // ht_empfname & ht_emplname are the
> values supplied by the user
> prepstmt3.setString(2,ht_emplname);
>
> ResultSet result = prepstmt3.executeQuery();
>
> Please help us out as we are stuck for quite a few days now.
>
> Thanks
>
> Nitin
>
> Mukul Gandhi wrote:
>
> > Hi Nitin,
> > u must have got Empfname and Emplname from HTML page stored in String
> > variables in ur servlet say f_var & l_var .
> > Now u can frame SQL query in ur program as -
> > Strin SQLStmt = "Select * from Empdet where Empfname like '%"+f_var+"%'
AND
> >  Emplname like '%"+l_var+"%'     (Pl note SQL specific syntax).
> > This should work ..
> > In SQL u give query like -
> > select * from Empdet where Empfname like '%abc%' and Emplname like
'%pqr%'
> >
> > (I am supposing Empfname and Emplname can contain the pattern sent
through
> > HTML page). If I am missing some point specific to ur problem, u can
> > reframe the query.
> >
> > -mukul
> >
> > At 05:22 PM 7/15/99 +0530, you wrote:
> > >Hello All
> > >
> > >We are trying to develop an servlet which talks with the MS-ACCESS
> > >database..
> > >
> > >We are also using prepared statement in the process. However we are
> > >facing problems in supplying parameters to the query at run time
> > >
> > >The querystring is as follows
> > >
> > >"Select * from Empdet where Empfname like ? AND  Emplname like ? ";
> > >
> > >We are accepting the first name and last name from the HTML page..
> > >
> > >To run on the Ms-Access the query should be like this
> > >
> > >Select * from Empdet where Empfname like '*<some char>*'  AND  Emplname
> > >like '*<some char>*' ";
> > >
> > >So we appended the '* and *' chars to the data accepted from the user
> > >and then inserted in the place of ? marks(place holders) using the
> > >setString() method..
> > >
> > >However the query deos not run successfully and returns a null
> > >resultset..
> > >
> > >Could any of you please help us with the construction of the query?
> > >
> > >Also is there any way we can know what the final query looks like after
> > >the ? marks have been replaced?
> > >
> > >Thanks
> > >
> > >Nitin Kulkarni
> >

____________________________________________________________________
Get your own FREE, personal Netscape WebMail account today at 
http://webmail.netscape.com.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to