|
Posted by Erland Sommarskog on 03/10/06 01:18
GANESH NAIDU (ganeznaidu@yahoo.com) writes:
> i need help in sql query my coding is as under
>
> Dim MRUNYEAR As String
> MRUNYEAR = "0405"
> Set fgrs = New Recordset
> fgrs.Open "select CT3HDR.CT3ID, CT3HDR.CT3NO,
> format(CT3HDR.ct3date,'dd/mm/yyyy'), suppmast.suppname FROM CT3HDR INNER
> JOIN suppmast ON CT3HDR.suppID=suppmast.suppid WHERE
> CT3HDR.RUNYEAR=MRUNYEAR ORDER BY CT3HDR.CT3NO", db, dbopenstatic,
> adLockOptimistic
>
> i am receiving error "no value given for one or more required parameter"
>
> if i give '0405' directly in the query than it is running fine. so how
> to give mrunyear variable in the query.
I'm a little surprised over the error; I would rather expect something
about an unknown column.
You would say
RUNYEAR = ?
And then you should use the Command object to define the query, and
the .CreateParameter method to add the parameter.
By the way, judging from the appearance of the Format function, it
appears that you are using Access. This is a newsgroup for SQL
Server, so you may not get the best advice here.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|