Showing posts with label named. Show all posts
Showing posts with label named. Show all posts

Wednesday, March 28, 2012

Parameter name getting garbled

I have a function that calls a sproc, and passes in a bunch of parameters. One of the parameters is named @.ProcessorEmail. Occasionally, the parameter name apparently gets garbled at runtime, as the following error occurs:

System.Data.SqlClient.SqlException: @.ProcessorEm??. is not a parameter for procedure gUser

The "@.ProcessorEm" part is always fine, then there will be various characters in place of the "ail" part.

Any ideas?Does your code hardcode the params or are they been fetched/constructed?|||They are hardcoded. The rest of the params are fine, it is always this same parameter that gets messed up. Again, it does not happen every time, just occasionally.|||Does the data your sending in the param contain any control codes or slighly odd unicode (i.e. taking data from a non .net source)?|||Actually, the parameter in question is being passed as an output parameter, so it does not have a value when I am passing it.|||What data is returned from the proc? Is it only outputs or a combination of outputs and record-sets?|||A combination of outputs. The sproc accepts a single input sproc, then the rest of the params are output params, with only a single record being returned. The param being passed in is an email address, which is the primary key constraint in the table, so there should be no dupes.|||Do you ensure that you've processed *every* row of the record set before you attempt to access the output params?|||Sorry, I misspoke. It is only output parameters, no recordsets.|||Odd one, are you sharing the command object or creating a fresh one each time?|||It's new on each instantiation. The command resides in a class I created called User. There are two constructors for User, one accepts the userid, the other accepts the email address. The only way to run the sproc is to create a new User object in my code.

Dim mUser as New User("me@.domain.com")

Parameter Mapping format string

Hi,

I have used Data Flow component that refers to named query of data source view. It is a OLE DB source.

The SQL Command property of data flow component shows SELECT * FROM Tablename as I defiend in named query. I have modified the query to accept a parameter as SELECT * FROM Tablename WHERE Status = ?

Now I need to pass the package variable to this parameter. How to I pass using ParameterMapping property?. What is correct way of passing the parameter mapping ? I tried with @.[TestNS:Tongue Tiedtatus] variable. But it throws error The parameter mapping string is not in the correct format.

Thanks in advance

Hello Prabha!

The best way to set parameter mappings on your OLE DB source is by using the "Parameters" button in the edit dialog for the source component. Once you've clicked that, a pop-up will appear with a grid where you can select variables you want to map to parameters of your SQL statement. If you have problems with this approach, feel free to post a follow up and one of us will be sure to help you from there.

Thanks, -David

|||

Hi David,

I agree that the suggested approch will help in configuing parameterized SQL Command. But my scenario is to use named query as source.

I do not get the 'Parameters' button as I have selected named query option in OLEDB source. However, I am allowed to change the SQL command property to have the parameter place holder '?' under Properties window after configuring the OLEDB connection Manager.

There is also one more property called 'ParameterMapping' under custom properties of OLEDB source. I do not find any reference on the format of the parameter mapping. Can you forward any reference on this ?

Thanks,

Prabha

|||

Sorry, Prabha, I sort of missed that you're using a DSV named query.

Officially, Named Queries don't support parameters, but as you found, there are ways to manually change the SQL in your DSV, such as by changing the xml directly. I wouldn't recommend that because other things using these DSVs are likely to break.

That having been said, I was able to convince the OLE DB source to bind in variables to the parameters I added manually to the Named Query's SQL, by setting the ParameterMapping manually. The format is:

"<param-name>","<variable-guid>";...

But, instead of constructing it manually, which seems kind of error prone, try this:

1) In the OLE DB Source editor, copy the SQL for your named query to the clipboard.

2) Switch to "SQL Command" mode for your OLE DB Source.

3) Paste the query from the clipboard to the SQL editor.

4) Click "Parameters...".

5) For each parameter, choose a variable.

6) Close the parameters screen, close the OLE DB source editor.

7) Find the "ParameterMapping" field in the Properties editor, copy that to the clipboard.

8) Re-open the OLE DB source editor, switch back to the Named Query.

9) Close the OLE DB source editor

10) Paste the ParameterMapping value from the clipboard back into the properties window

A lot of steps, but I think it's better than trying to hand-assemble the thing. Fair warning though, this isn't supported, so it could stop working at any time. From what I know, DSVs don't officially support parameters, so the safe bet would be to switch to SQL Command mode for this.

-David

|||

Thank you so much David, The given work around works well.

- Prabha

Parameter label field

How do I refer to the label field of a parameter? I have a parameter named
Group with a lable field of 'HR' and value field of 23. I'm puting a text
box at the top of my report with the parameters in it. I dont want to
display '23' (which is what Parameters!Group.Value returns), I want to
display 'HR'
Thanks,
DougI almost hate to tell you this.
Parameters!Group.Label
The expression builder doesn't show you this but just type it in.
Bruce L-C
"Doug Stiers" <doug@.nospam.com> wrote in message
news:OhP5onOlEHA.3356@.TK2MSFTNGP15.phx.gbl...
> How do I refer to the label field of a parameter? I have a parameter named
> Group with a lable field of 'HR' and value field of 23. I'm puting a text
> box at the top of my report with the parameters in it. I dont want to
> display '23' (which is what Parameters!Group.Value returns), I want to
> display 'HR'
> Thanks,
> Doug
>|||I cant believe I didnt think of that. Thanks.
Doug
"Bruce Loehle-Conger" <bruce_lcNOSPAM@.hotmail.com> wrote in message
news:%23DCmz7OlEHA.596@.tk2msftngp13.phx.gbl...
> I almost hate to tell you this.
> Parameters!Group.Label
> The expression builder doesn't show you this but just type it in.
> Bruce L-C
> "Doug Stiers" <doug@.nospam.com> wrote in message
> news:OhP5onOlEHA.3356@.TK2MSFTNGP15.phx.gbl...
> > How do I refer to the label field of a parameter? I have a parameter
named
> > Group with a lable field of 'HR' and value field of 23. I'm puting a
text
> > box at the top of my report with the parameters in it. I dont want to
> > display '23' (which is what Parameters!Group.Value returns), I want to
> > display 'HR'
> >
> > Thanks,
> > Doug
> >
> >
>

Monday, March 12, 2012

Paging Technique

Questoin

I am using Sql Server 2000.

I have a table named Cities which has more than 2600000 records.

I have to display the records for a specific city page wise.

I don't want to compromise with performance.

Can anyone has the idea?

Waiting for your fruitful response.

Happy Day And Night For All

Muhammad Zeeshanuddin Khan

Hi Muhammad,

Check out this article. The idea behind is that you only fetch the records from the database that you display on the active pageIndex.

Succes!

Rutger van Hagen