- paypal ipn returns invalid
- cannot manually edit applicationhost.config
- must declare the scalar variable
- classic asp and access not working on windows 2008 64bit
- asp.net page titles are blank
- sql to get totals for last six months
- white space being counted as a node
- cross page posting not working
- collection is read only exception
- PayPal sending incorrect carrier information
- paypal guest user notice
- classic asp dictionary not working
- IE8 not supporting innerHTML
- differences between jet and odbc
- sugarcrm not inserting email
- select random records from access
- button click event firing twice
- how to send an email using cdosys
- installing perl on win2003 64 bit
- asp.net page event order
- rewrite rule for subdomains only
- extra items in javascript array
- IE7 margin auto not working
- IE7 border style dotted glitch
- ByRef and ByVal in vbscript
- weather rss feed
- Classic asp crib sheet
- Firefox onsubmit image change
- limit records in access
- AccessDataSource is thick
- double margins in IE6
- extra image padding in html emails
- decimal places in linux flash player
- broken emails in outlook 2007
- double spaced IE list items
- cannot remove movieclip
articles:
must declare the scalar variable
There are two commmon reasons for this error:
- The parameter is simply misspelled
- When using OleDb the parameters in the SQL are to be set to ? and not @paramname
For more details on these see http://blogs.msdn.com/b/spike/archive/2010/03/03/must-declare-the-scalar-variable.aspx
But there is a third reason i've yet to see documented:
When adding parameters to an sqldatasource programmatically you need to omit the @ sign at the beginning of the paramater name.
E.g.
mySqldatasource.insertparameters.add("@myparam",value)
mySqldatasource.insertcommand = "INSERT INTO myTable (myparamfield) values (@myparam)"
will return this error when you run the insert command:
System.Data.SqlClient.SqlException: Must declare the scalar variable @myparam
The code needs to be:
mySqldatasource.insertparameters.add("myparam",value)
mySqldatasource.insertcommand = "INSERT INTO myTable (myparamfield) values (@myparam)"
Note how the param in the parameters collection doesn't have an @ sign, but the reference to it in the command does.
Post a comment
