Showing posts with label straight. Show all posts
Showing posts with label straight. Show all posts

Wednesday, March 28, 2012

I don't understand why

I have posted this problem for 2 weeks straight and I cannot possibly believe I'm the only one here having this issue. Can someone please help or explain why or how I can resolve this problem?

http://www.eggheadcafe.com/forums/ForumPost.asp?ID=60046&INTID=9

Try using alias name for the column in the storproc 's slq query like

select sum(tickets) Tic from Table1,

u will be able refer the column by the name - < Tic > - in the SSRS

|||I'm doing this! In my stored proc I return a value at the end just like you said. If you read, the problem is in SSRS when I reference that field in my table, not my stored proc. If you grab that field from your dataset that runs the stoerd proc, for sum reason SSRS puts SUM() around it which I don't want.|||

i got it

u r trying sum a field in a text box

u r using expression for it

use always "="(equals) in front of ur expresssion , like =sum(Fields!xyz.value) , assuming xyz is ur field name.

if u do not use "=" in an expresssion it becomes a string and believes sum is also part of that string

hope it helps

suresh babu

sureshk@.dcons.com

|||I did use an expression, there is an =. Look at my links....it's an expression inside my footer field trying to reference a texboxname from my group. I'm way beyond this. I don't undertand why nobody is getting my problem here. It's simple. I'm not just referencing one or two fields from my dataset in my expression. This report is way complicated. Therfore I'd like to be able to sum a whole column in my footer simply by referencing the texbox name in my group and do a SUM on that name....get it? Look at all the *** I posted..look closely at what I'm trying to do...reference a named textbox that's in my group, and do an =SUM(group texboxt name ) whcih you can't, because a group textbox is out of scope..you can't reference a group texbox name from a footer expression....which is totally nonsense

Friday, March 23, 2012

I can't get a SQL QUery to accept a null for a parameter

I have straight forward Insert Query, which takes values mainly from text boxes, however I am having trouble when the value is null.

eg
cmdP0.Parameters["@.EmpID"].Value=txtEmpNo.Text;

When I run the Query I get...
Message="Parameterized Query '(@.ID int,@.EmpID int,@.Photo nvarchar(260),@.DoB smalldatetime,@.Med' expects parameter @.EmpID, which was not supplied."

I also get this when the parameter can be a string.
I have set the parameter properties so that SourceColumnNullMaping to true (it was set as false - so hoped this might fix it!)

No luck.

Have you tried to set DBNull.Value as value of the parameter, if the text is returned as null?|||

That worked for the strings it took a bit of effort forn integers.

Thanks to someone eles code, which I don't quite understand...

string inputGap = txtGap.Text;
Int32? searchGap = null;
if(!string.IsNullOrEmpty(inputGap)) {
Int32 Gap;
if(Int32.TryParse(inputGap , out Gap))
searchGap = Gap;
}
if(searchGap!=null) {
cmdP0.Parameters["@.MedicalGap"].Value=searchGap;
} else {
cmdP0.Parameters["@.MedicalGap"].Value=DBNull.Value;}

I don't know what Int32? searchGap = null; does

|||

Int32 is a struct (a value type). That means it can't be null. .NET 2.0 adds so called Nullable Types. That means you can set an Int32 null, by using a special syntax. Int32? (with the question mark) means that this is a nullable. It means that this variable can be set to null.

This piece of code is to complex. You can make it a lot easier by doing this:

int value = 0;
if (int.TryParse(txtGap.Text, out value))
cmdP0.Parameters["@.MedicalGap"].Value = value;
else
cmdP0.Parameters["@.MedicalGap"].Value = DBNull.Value;

|||

Thank you

A nice clear explanation and some nice code

Much appreciated, this has been driving me nuts!