Decimal value become another value - asp.net

Why when i pass this parameter to sqldatasource parameters i see the correct defaultvalue but an incorrect parameter value? i don't know the difference between these two types of parameters, i Always think that default value is what is for my interest. I want to send in DB value 7.5 and not 75, could anyone help me please?
Parameter prm_prezzo = new Parameter("cc_prezzo", DbType.Decimal, newValues["PREZZO"].ToString().Replace(",", "."));

Solved but i would an expert's think about this because it's not clear for me:
the first instruction that i post had the replace of "," with "." because without the replace the "," escape the stored procedure
doing so...
Parameter prm_prezzo = new Parameter("cc_prezzo", DbType.Decimal);
prm_prezzo.DefaultValue = newValues["PREZZO"].ToString();
...i have the correct value and the stored procedure is not escaped...
but i don't undestand the difference between the two methods :-0

Related

TALES expression to compare numeric input in Plone?

TALES expression is new to me. Can I get some good reference for the same? Actually I wish to define a content rule for numeric input field using ploneformgen. Something like:
python: request.form.get('amt', False) <= 5000
then apply the rule.
Here 'amt' is a numeric/whole number field on the input form.
For reference, you should look at the official TALES specification, or refer to the TALES section of the Zope Page Templates reference.
In this case, you are using a plain python expression, and thus the normal rules of python code apply.
The expression request.form.get('amt', False) would return the request parameter 'amt' from the request, and if that's missing, return the boolean False, which you then compare to an integer value.
There are 2 things wrong with that expression: first of all you assume that the 'amt' parameter is an integer value. Even a PFG integer field however, is still a string in the request object. As such you'll need to convert in to an integer first before you can compare it.
Also, you fall back to a boolean, which in integer comparisons will be regarded as the equivalent of 0, better be explicit and use that instead:
python: int(request.form.get('amt', 0)) <= 5000
Note that for a PFG condition, you can also return a string error message instead of boolean True:
python: int(request.form.get('amt', 0)) <= 5000 or 'Amount must be not be greater than 5000'
Usually form parameters are passed in as strings if they are not defined on the application level otherwise e.g.
Zope will under the hood use the fieldname amt:int in order to convert the value to an integer.
So you may want to try to put an int(....) around the first expression.

SSIS: Comparing datetime with a variable

So, I have created a variable "batch" with datatype datetime. Now my OLEBD source has a column "addDate" eg 2012-05-18 11:11:17.470 so does empty destination which is to be populated.
now this column addDate has many dates and I want to copy all dates which are "2012-05-18 11:11:17.470"
When I put value of the variable as this date, it automatically changes to mm/dd/yyyy hh;mm AM format and hence in my conditional split transformation, it couldn't match the date with the variable and hence no records are getting copied to the destination !!
Where exactly is the problem?
Thanks!
I had this issue and the best solution I found is not “pretty”.
Basically you need to change the “expression” of the variable and the “evaluate as expression” to true (otherwise it will ignore the value on expression).
The secret is (and kind of the reason I said it is not a pretty solution) to create a second variable to evaluate the expression of the first variable because you can’t change the value of a variable based on a expression.
So let’s say your variable is called “DateVariable” and you have 23/05/2012, create a variable called “DateVar2” for example and set its expression to
(DT_WSTR,4)YEAR(#[User::DateVariable]) + "/"+RIGHT("0" +
(DT_WSTR,2)MONTH(#[User::DateVariable]),2) + "/" + RIGHT("0" +
(DT_WSTR,2)DAY(#[User::DateVariable]),2)
That will give you 2012/05/23
Just keep going to get the date on the format you want
I found the easier solution. Select datatype as string. put any desired value.
Before conditional split, you need data conversion transformation.
convert it into DT_DBTIMESTAMP then run the package.
It works!

Can someone please explain what the following code does?

I'm currently working on a project that was written in classic asp. I've used this language some before but I'm rusty with it.
In that code I see the following function call:
Result = SwapOEMPart(sItem)
When I look at SwapOEMPart I see this:
function SwapOEMPart(oemPart)
// Do a bunch of stuff
oemPart = objRS("CCIPartNo") <-- this is the result of the stuff
end function
What does that do? Does it fill Result with the value of oemPart? Does it change the value of sItem (similar to a pass by reference)? Or perhaps it is something entirely different.
I'm familiar with returning data from asp functions by setting the function name equal to the value you want to return, but in this instance they are changing the value of the parameter they pass in and then just ending the function.
Based on the code you have provided, I'm going to assume objRS is an adodb.recordset, if that is the case, CCIPartNo is a column in the recorset, all your code is doing is writing the value of that column into the eomPart variable - eomPart isnt referenced as byref in the function declaration but this is assumed as default if you're in vbscript (not .net) so **it's almost as if the value of the column is being passed back into eomPart & because eomPart is a REFERENCE to the sItem value in your example, the actual value of sItem would change.
http://msdn.microsoft.com/en-us/library/ee478101%28VS.84%29.aspx

I have a problem with my SQL statement

Threads
-------
ThreadID
UsersID
Date
ThreadTitle
ThreadParagraph
ThreadClosed
Topics
-----
TopicsID
Theme
Topics
Date
Here is my statement:
StringBuilder insertCommand = new StringBuilder();
insertCommand.Append("DECLARE #TopicsID int");
insertCommand.Append("INSERT INTO Topics(Theme,Topics,Date)");
insertCommand.Append("VALUES(#topic,#subTopic,GETDATE())");
insertCommand.Append("SET #TopicsID = SCOPE_IDENTITY()");
insertCommand.Append("INSERT INTO Threads(UsersID,TopicsID,Date,ThreadTitle,ThreadParagraph,ThreadClosed)");
insertCommand.Append("VALUES(#uniqueIdentifier,#TopicsID,GETDATE(),#questionTitle,#questionParagraph,0)");
I get this:
Incorrect syntax near the keyword
'INTO'. Must declare the scalar
variable "#TopicsID". Must declare the
scalar variable "#TopicsID".
The first thing I notice is:
insertCommand.Append("VALUES('#topic,#subTopic,GETDATE()')");
might need to be:
insertCommand.Append("VALUES(#topic,#subTopic,GETDATE())");
It looks like you have some extra single quotes in there.
You need a semi-colon after DECLARE #TopicsID int
That will take care of the "incorrect syntax" and declaring the scalar variable.
And I believe that you need to remove the single quotes around your three VALUES. That is causing it to think you have supplied only one VALUE instead of three.
Try
insertCommand.AppendLine
SQL sees
DECLARE #TopicsID intINSERT INTO Topics(Theme,Topics,Date) ...
You need to separate the distinct statements
Your single quotes on the last line are wrong - its turning it all onto one string:
Change
insertCommand.Append("VALUES('#uniqueIdentifier,#TopicsID,GETDATE(),#questionTitle,#questionParagraph,0')");
to
insertCommand.Append("VALUES(#uniqueIdentifier,#TopicsID,GETDATE(),#questionTitle,#questionParagraph,0)");

In Classic ASP, how do I reference a variable based on a string?

I have many constant variables for example:
Const Total_US_Price = "100"
However, in my code, I am pulling a string "Total_US_Price". I want to replace my string with the value of the Const variable.
How do I do that? How do I change "Total_US_Price" to return "100" (both being strings)?
It sounds like you want to use the eval() function...
http://www.devguru.com/technologies/vbscript/QuickRef/eval.html
EDIT: I hope you're not pulling these strings from the client side (query string, POSTed form values, or cookies) or else you are opening yourself up for a world of hurt. Someone could inject whatever strings they wanted and it will get executed on your web server.
Not sure what you exactly mean with 'pulling a string' but please don't abuse eval. Use a lookup table for lookup values.
set x = createobject("scripting.dictionary")
x("total_us_price") = 100
price = x("total_us_price")
You would use the "CInt " function.
VBScript CInt Function explained and usage.
I don't think this can be done other than by executing code dynamically, using either Eval() to get the value directly, or Execute() to get it by side-effect.
Specifically:
MyVarName = "Total_US_Price"
Value100 = Eval(MyVarName)
' Or...
Exectute("Value100 = " + MyVarName)
The Eval is more practical, but less flexible...

Resources