Showing posts with label passing. Show all posts
Showing posts with label passing. Show all posts

Monday, March 26, 2012

Question regarding creating If Else functions in my report

Hi, I'm new and i'm having trouble trying to create this query at the "DATA" tab of my rdl.

What i'm trying to do here is passing 2 employee name from two drop

down text box(doing a filtering with "From Employee" and "To

Employee"), and assign it to a global variable which i declared.

Is there something i miss out or i did worng which cause a error

"Incorrect syntax near the keyword 'BEGIN'. (.Net SqlClient Data

Provider)".

It would be so helpful of you if links of website or previous post or

any reference are provided, which give some basic tutorial on how to

create codes as shown below.

Thanks in advance

DECLARE @.G_StartEmp AS CHAR(10), @.G_EndEmp AS CHAR(10)


IF @.StartEmp > @.EndEmp

BEGIN

Set @.G_StartEmp = @.EndEmp

Set @.G_EndEmp = @.StartEmp

END

ELSE

BEGIN

Set @.G_StartEmp = @.StartEmp

Set @.G_EndEmp = @.EndEmp

END IF


BEGIN

select * from EMPLOYEE

where employeename between G_StartEmp and G_EndEmp

END

DId you wrap that code in a stored procedure ?

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||Hi, after spending some time again on this, i realize i added an extra "IF" , which is the cause of this error.

Thanks for taking your time to reply me Jens K. Suessmeyer.

DECLARE @.G_StartEmp AS CHAR(10), @.G_EndEmp AS CHAR(10)


IF @.StartEmp > @.EndEmp

BEGIN

Set @.G_StartEmp = @.EndEmp

Set @.G_EndEmp = @.StartEmp

END

ELSE

BEGIN

Set @.G_StartEmp = @.StartEmp

Set @.G_EndEmp = @.EndEmp

END (Originally was "END IF")


BEGIN

select * from EMPLOYEE

where employeename between G_StartEmp and G_EndEmp

END

Monday, March 12, 2012

Question on passing multi-value parameter for multiple branches

Hello. We are using asp .net and reporting services, and trying to pass a multi-value parameter into reporting services that will show data for multiple branches.

Dim paramList As New Generic.List(Of Microsoft.Reporting.WebForms.ReportParameter)

paramList.Add(New Microsoft.Reporting.WebForms.ReportParameter("BranchNumber", 1))

ReportViewer1.ServerReport.SetParameters(paramList)

pInfo = ReportViewer1.ServerReport.GetParameters()

Let me know if you have any suggestions!

Thanks.

Did you try passing "1,2,3,4" instead of "1" ?

Jens K. Suessmeyer

http://www.sqlserver2005.de
|||We tried that also, without any luck.|||

We have already figured out how to move between seperate branches, we just want a corporate option that will show all branches as a whole.

Any ideas?

Thanks

|||There is no way to post the "All" option, you will either have to pass all values to display or use an additional (hidden) parametert which uses the "All" option behind the scenes, something like:

Where SomeVar IN (@.TheValues) OR @.TheMagicParameter = 1 (Where TheMagicParameter is the magic hidden parameter)

Jens K. Suessmeyer.

http://www.sqlserver2005.de

Saturday, February 25, 2012

Question on correct syntax for stored procedure

I have an ASP.NET datagrid in which I am passing the following:
PartNumber (which is actually a varchar)
PartType (varchar)
The PartType is just the description. In the PartType table I have two field
s:
ptID (what I actually need to access)
Description (what is being passed to the stored procedure)
What I want to do is insert into the Parts table the PartNumber (no problem)
and the ptID.
When I call existing records I use the following SQL statement:
SELECT p.PartNumber, p.ID as ptID, pt.description FROM parts p INNER JOIN
PartTypes pt on pt.ID =p.PartTypeID WHERE p.PartNumber = @.PartID;
What I am trying to figure out is where in the stored procedure do I fit the
inner join? This is what I have thus far:
@.PartNumber varchar (15),
@.PartType varchar (100),
AS
if NOT EXISTS (Select * from Parts where PartNumber = @.PartNumber)
BEGIN
insert into Parts
(PartNumber, PartTypeID)
VALUES
(
@.PartNumber
@.PartType <--but I don't actually want the PartType, I want the PartTypeID
)
END
How do I do this? Let me know if you need more info. Thanks!Leckey,
You can fire the query you have mentioned just before the insert statement
which
you have given in your stored procedure. Query would be something like
SELECT p.PartNumber, @.PART_ID = p.ID as ptID, pt.description FROM parts p
INNER JOIN
> PartTypes pt on pt.ID =p.PartTypeID WHERE p.PartNumber = @.PartID;
@.PART_ID need to be declared within the SP as an integer type variable. Now
you can this
@.PART_ID in your insert statement as the second param.
Hope this helps.
Regards,
Joe.
"leckey" <u23706@.uwe> wrote in message news:62b346eec9d0a@.uwe...
> I have an ASP.NET datagrid in which I am passing the following:
> PartNumber (which is actually a varchar)
> PartType (varchar)
> The PartType is just the description. In the PartType table I have two
fields:
> ptID (what I actually need to access)
> Description (what is being passed to the stored procedure)
> What I want to do is insert into the Parts table the PartNumber (no
problem)
> and the ptID.
> When I call existing records I use the following SQL statement:
> SELECT p.PartNumber, p.ID as ptID, pt.description FROM parts p INNER JOIN
> PartTypes pt on pt.ID =p.PartTypeID WHERE p.PartNumber = @.PartID;
> What I am trying to figure out is where in the stored procedure do I fit
the
> inner join? This is what I have thus far:
> @.PartNumber varchar (15),
> @.PartType varchar (100),
> AS
> if NOT EXISTS (Select * from Parts where PartNumber = @.PartNumber)
> BEGIN
> insert into Parts
> (PartNumber, PartTypeID)
>
> VALUES
> (
> @.PartNumber
> @.PartType <--but I don't actually want the PartType, I want the PartTypeID
> )
> END
> How do I do this? Let me know if you need more info. Thanks!