Showing posts with label integer. Show all posts
Showing posts with label integer. Show all posts

Friday, March 23, 2012

problem with IN (@intParameter) in a stored procedure

I want to pass a list of integer values as a parameter for a stored procedure where the criteria column is an integer

I understand what the problem is but I cannot seem to find a solution, I can't pass it as a varchar because the column is an int and I can't pass it as an in because of the commas in the list

SELECTAppId, ApplicationName, NextPage, AppData, GrpLogo, DeptLogin
FROMdbo.TblApplication
WHERE(AppIdIN(@.intParameter))
ORDER BYSortOrder, ApplicationName

any help please

This question has been answered a few times, with sample code in the solution. Please search in these forums. I am sure you will find it.|||Search for the Split function.|||

thanks for that I found304221 Terri Morton's bit did the trick

|||

I did as you suggested and found 304221 from Terri Morton's did just what I wanted

Many Thanks

Tuesday, March 20, 2012

Problem with Format() Function in expression

Hi,
I have a textbox with an expression to format integer data:
="HH: " + format(Fields!ANZHH.Value,"#.###.") + ", EW: " +
format(Fields!ANZEW.Value,"#.###.")
I want that integer values appear as: HH: 1.000, EW: 3.890
("." = group digit )
However the custom format style that I use does not return the expected
result, instead RS shows HH: 1000, EW: 3890
Any ideas how to troubleshoot?
--
Thanks in advance
BodoI finally got it solved:
1) modified expression to:
="HH: " + format(Fields!ANZHH.Value,"#,###.") + ", EW: " +
format(Fields!ANZEW.Value,"#,###.")
2) set report property Language to Default.
As a result values are formated in the culture specified in IE language
settings.
Bodo|||I'm guessing I'm not the first to ask this, but haven't found anything
either here or via googling around.
Per the subject, some of our database fields have html code in them that we
would like to render inside the report (using the table control) as actual
html instead of just code, is this at all possible with some toggles or
perhaps expression injection? Its mostly stuff like fonts colors/sizes/etc,
nothing drastic, but of course its showing up as a bunch of
<this><that>...etc rathern than actual html.
Please let me know either way, or perhaps point me to an example somewhere?
TIA.
andy|||Apologies for the above :(
"Andrzej E. Raczynski" <andy@.aea13.org> wrote in message
news:9CA7AD98-7309-4C21-B000-46E7CDFD429C@.microsoft.com...
> I'm guessing I'm not the first to ask this, but haven't found anything
> either here or via googling around.
> Per the subject, some of our database fields have html code in them that
> we would like to render inside the report (using the table control) as
> actual html instead of just code, is this at all possible with some
> toggles or perhaps expression injection? Its mostly stuff like fonts
> colors/sizes/etc, nothing drastic, but of course its showing up as a bunch
> of <this><that>...etc rathern than actual html.
> Please let me know either way, or perhaps point me to an example
> somewhere?
> TIA.
> andy

Monday, March 12, 2012

Problem with ExecuteNonQuery

I have created a stored procedure that takes several parameters and ultimately does an INSERT on two tables. The sp returns with an integer indicating which is positive if one or more rows were added.

If I execute the SP by hand using the SQL Server Management Studio Express I get the proper results, the records are added to both tables and the return values are proper. One is an output parameter indicating the Identity value of the main record, the return value simply >0 if OK.

However, when I use C#, build my connection, command and its associated parameters making sure they match the SP then I get a malfunction.

The problem is that when I call ExecuteNonQuery the integer value it returns is -1 even though calling it from Mgmt. Studio gives a >0 result. Even though it returns -1 I can confirm that the records were added to BOTH tables and that the output parameter (The identity) given to me is also correct. However the return value is always -1.

I have no idea what is going wrong, Since I have SQL Express 2005 I do cannot do profiling :(. I really don't see why this goes wrong and I think using ExecuteScalar is not the best choice for this type of action.

ExecuteScalar is used for database calls that return one and only one value. This sounds like what you're doing. Why don't you think that ExecuteScalar is appropriate for this?

|||

The return Value from ExecuteNonQuery retuns number of rows effected. It is better to use ExecuteScalar but not must. For execute nonquery commnd, 0th [zero] command parameter is your return value. try to access that. If you dont get then create another parameter to ur sp @.newID OUTPUT, and set that in u r sp @.newID = @.@.IDENTITY. and access that in your CommandObject after executing ExecuteNonQuery();

|||

Are you checking the return value from the ExecuteNonQuery function, or the parameter with type ReturnValue?

result=cmd.ExecuteNonQuery()

or

cmd.Parameters.Add("@.RETURN_VALUE",sqldbtype.Int).ParameterDirection=ReturnValue

cmd.executeNonQuery()

result=cmd.Parameters("@.RETURN_VALUE").Value

?