Select Parameter Declaritively Set To A Public Property Value?
Oct 23, 2007
Hi,
I was wondering about the possiblity of setting a SelectParameter for my SQLDataSource declaritively, using a public property value.
Something like this:
<SelectParameters>
<asp:Parameter Name="CategoryIdLvl3" DefaultValue='<% SelectedCatLvl3%>' Type="String" />
</SelectParameters>
So the default value automically processes Public Property value of SelectdCatLvl3, which is declared in my code behind.
Of course this syntax is incorrect, but if someone can help, much appreciated.
I don't want to set this parameter in code behind, because I'd have to do it mulitple times, so was hoping this method would somehow work.
thanks..
I have an SqlDataSource control on my aspx page, this is connected to database by a built in procedure that returns a string dependent upon and ID passed in. I have the followinbg codewhich is not complet, I woiuld appriciate any help to produce the correct code for the code file Function GetCategoryName(ByVal ID As Integer) As String sdsCategoriesByID.SelectParameters("ID").Direction = Data.ParameterDirection.Input sdsCategoriesByID.SelectParameters.Item("ID").DefaultValue = 3 sdsCategoriesByID.Select() <<<< THIS LINE COMES UP WITH ERROR 1End Function ERROR AS FOLLOWS argument not specified for parameter 'arguments' of public function Select(arguments as System.Web.DatasourceSelect Arguments as Collections ienumerable
Help I have not got much more hair to loose Thanks Steve
Every night, there are some stored procedures that run to recreate tables so that the information in the table is updated. After the tables are droped and recreated I have to go in and check the select box under the permissions for the public role. If i don't do this users will not be able to select from theres tables.
What can I do so that users are able to select from these tables after they are created?
Would you be able to specify the select permissions for the public role in the script that creates the table or run a script that gives all those tables select permissions for the public role?
I am working with SQL Server 2012. I have deployed a SSIS project that has 2 packages in it. The package connection manager (Test) uses an expression to evaluate one of the Project parameter value (TestConnectionString) to set its ConnectionString property.
This works fine in a Dev environment. However when deployed to UAT, it keeps failing with the error:
PackageExport:Error: The result of the expression "@[$Project::TestConnectionString]" on property "Package.Connections[Test].Properties [ConnectionString]" cannot be written to the property. The expression was evaluated, but cannot be set on the property.
I can not seem to find what the issue could be. I have come across [URL] .... where it says: "If the package contains project parameters, the package execution may fail." but offers no solution.
Hi, I have declared an internal paramter and given the default non queried value as
select @split = case when max(rowid)%2 = 1 then (max(rowid)/2) + 1 else max(rowid)/2 end
and when i run it i am getting the error -- The property 'DefaultValue' of report parameter split doesnt have the expected type. What should i do to solve it. Any help is appreciated.
I have a query in which I'd like to use the username of the user currently logged in. The expression im using to retrieve the username is: Membership.GetUser().UserName. Currently I have the following: <asp:SqlDataSource ID="ProjectSource" runat="server" ConnectionString="<%$ ConnectionStrings:Code %>" ProviderName="<%$ ConnectionStrings:Code.ProviderName %>" SelectCommand="Select Name, Namespace from Project where User = $Username"> <SelectParameters> <asp:Parameter DefaultValue="" Name="$Username" /> </SelectParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="ProjectSource" />I'd somehow like to set up $Username to be equivlent to Membership.GetUser().UserName.
I have a dataset listing distinct values for items (like 1, D10, M4, etc.) The WHERE statement in my query refers to unit IN(@Unit). I then have 2 report parameters to select 1) a date (datetime); and 2) a multivalue parameter to select one or all of the "units". I would like the second parameter to default to "Select All". Can someone tell me how to do this? I'm sure this is a fairly simple thing but I am really struggling. The report parameter is set as multivalue; My "available values" is set to "from query" and refers to my "unit" dataset and the value and label fields are set to "unit" (only field I bring into this particular dataset). The "Default Values" section is set to "from query" , the dataset is set to "unit" and the value is set to "unit". I can preview the report and select a date but the list of units comes up with all boxes unchecked, including "Select All". Any help will be much appreciated. Thanks.
I am having problems exporting data into a flat file using specific code page. My application has a variable "User::CodePage" that stores code page value (936, 950, 1252, etc) based on the data source. This variable is assigned to the CodePage property of desitnation file connection using Property expression.
But, when I execute the package, the CodePage property of the Destination file connection defaults to the initial value that was set for "User:CodePage" variable in design mode. I checked the value within the variable during runtime and it changes correctly for each data source. But, the property of the destinatin file connection doesn't change and results in an error.
[Flat File Destination [473]] Error: Data conversion failed. The data conversion for column "Column01" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
[DTS.Pipeline] Error: The ProcessInput method on component "Flat File Destination" (473) failed with error code 0xC02020A0. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.
If I manually update the variable with correct code page and re-run the ETL, everything works fine. Just that it doesn't work during run-time mode.
I developed a simple custom control flow component which has several read/write properties and one readonly property (lets call it ROP) whichs Get method simple returns the value of a private variable (VAR as string). In the Execute method the VAR has a value assigened. When I put the value of ROP or VAR into MsgBox I can see the correct value. However when I execute the component I can not see the value of the ROP in the property window. I see the property but its value is empty string. For example when I put a breakpoint to postexecute or check the property before click OK in a MsgBox I would expect that the property value would be updated in SSIS as well. Is there a way how to display correct values of custom tasks properties in property window?
Untill recently I had a smooth running SSIS package,but suddenly it throws error syaing "OnError,,,,,,,The result of the expression
"@[User:trTextFileImpDirectory] +"SomeTextStringHere"+ @[User:trANTTextFileName] +(DT_STR,30,1252) @[User:taging_Date_Key]+ "SomeTextStringHere" " on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property."
I have child SSIS package running under a parent package (through execute package task)
I have few flat file connection managers in child package for text file import , in which I am building text file path dynamically at run time by assigning an expression in connection string property of connection manager. The Expression is as follows
Where @[User:trTextFileImpDirectory] is a variable which contains path of directory containg text files.Value in this variable is assigned at runtime from parent package's variable,which in turns fetch value from a configuration file on local server.
With my current configuration this path has been configured to some other server's directory over network ( I.e my package picks text files from some other servers folder over network)
While "Some string here"+ @[User:trANTTextFileName]" part of file name string.
(DT_STR,30,1252) @[User:taging_Date_Key] Contain the date of processing ,value in this variable is also picked up at run time from parent package variable.
1) So can someone give me some insight into possible reason of failures. 2) Is it possible that problem arises if directory (from which I m picking text files) is assigned password or is there exist some problem in accessing forlders over network ? 3) Or there can be some problem in package configuration at design time( I.e where I m assigning value in variable from parent package vriables)?
I have this semi-complex query that is selecting items from numerous tables residing on 2 different databases. So far the query works perfectly. Here is the problem: The user is given the option of selecting items based on whether a course is Completed (C) Incomplete (I) Passed (P) Failed (F) or (ALL). I am not really sure how to do the select all, the others I can do depending on the value...
Any thoughts??
Query:
sql Code:
Original - sql Code
ALTER PROCEDURE [dbo].[Sel_CourseActivityPerUser] ( @status varchar(25), @course varchar(100), @datesmalldatetime ) AS
I am using RS 2000. I have a multi select parameter where I can select multiple states by separating with a comma. I am trying to figure out how to incorporate an "All" parameter.
Query:
Select [name], city, state, zipcode From Golf inner join charlist_to_table(@State,Default)f on State = f.str
Function:
CREATE FUNCTION charlist_to_table (@list ntext, @delimiter nchar(1) = N',') RETURNS @tbl Table (listpos int IDENTITY(1, 1) NOT NULL, str varchar(4000), nstr nvarchar(2000)) AS BEGIN DECLARE @pos int, @textpos int, @chunklen smallint, @tmpstr nvarchar(4000), @leftover nvarchar(4000), @tmpval nvarchar(4000) SET @textpos = 1 SET @leftover = '' WHILE @textpos <= datalength(@list) / 2 BEGIN SET @chunklen = 4000 - datalength(@leftover) / 2 SET @tmpstr = @leftover + substring(@list, @textpos, @chunklen) SET @textpos = @textpos + @chunklen SET @pos = charindex(@delimiter, @tmpstr) WHILE @pos > 0 BEGIN SET @tmpval = ltrim(rtrim(left(@tmpstr, @pos - 1))) INSERT @tbl (str, nstr) VALUES(@tmpval, @tmpval) SET @tmpstr = substring(@tmpstr, @pos + 1, len(@tmpstr)) SET @pos = charindex(@delimiter, @tmpstr) END SET @leftover = @tmpstr END INSERT @tbl(str, nstr) VALUES (ltrim(rtrim(@leftover)), ltrim(rtrim(@leftover))) RETURN END GO
When passing the prameter values to a linked report, I want to set one of the parameter at the linked report to "Select All", this was added automatically to the parameter list when multivalue report parameter is used . How to set this "Select All" as a parameter or can it be done? Thanks
Hi I will like to bind the listbox control only with the rows where the colums text = categoryX Where do I declare the variable @Category ? If Not Page.IsPostBack Then Dim conPubs As SqlConnection Dim cmdSelect As SqlCommand Dim dtrAuthors As SqlDataReader conPubs = New SqlConnection(ConfigurationSettings.AppSettings("connectionstring")) conPubs.Open() cmdSelect = New SqlCommand("Select * From Slideshows WHERE ([Slideshows].[Category] = @Category)", conPubs) dtrAuthors = cmdSelect.ExecuteReader() ListBox1.DataSource = dtrAuthors ListBox1.DataBind() dtrAuthors.Close() conPubs.Close() End If Best Regards
The header table row for G4 contains 3 textboxes containing the sums of the contents within G4. The header table row for G4 is visible while it's contents, including the G4 footer table row, is kept invisible until the report user drills down into the group.
When the report user drills down into G4 the footer table row becomes visible and the sums of the contents of the group are displayed for a second time.
At this point I want the sums in the header to be set to invisible when the sums in the footer are made visible by the drilldown.
When I try to reference the hidden property of textbox66 in the G4 footer in order to set the hidden property of header textbox57 in the G4 header I get to this point...
=IIF(reportitems!textbox66.
When it fails to give me an option of choosing the .Hidden property and instead only gives me a .Value.
If I complete the IIF statement manually so that it spells out .....
So my question is, how do I reference the hidden property of one or more textboxes in a group to use as condition checks to set the hidden property of another textbox in that same group?
Thank you for any help you can provide. We are only now beginning to implement reporting services and I have not yet had the chance to research this in greater detail for lack of time.
I'm sure that is really simple, but how do I pass a parameter with multiple value to a SQLdatasource? ex: SELECT field1 from tblTableA where idTableA IN ( @Param1) Let's say I want to pass 1,2,3,4 as Param1 (SELECT field1 from tblTableA where idTableA IN ( 1,2,3,4)) How I am supposed tu use the .SelectParameters.Add() to pass a list of integers instead of a single value?? Thanks in advance.
Is it possible to use a WHERE-IN statement with a SqlDataSource control. For instance: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="SELECT [Id], [Name], [Phone] FROM [Table1] WHERE ([Id] IN @Id)"> <SelectParameters> <asp:Parameter DefaultValue="( 1, 3, 5, 7, 11 )" Name="Id" Type="Int32" /> </SelectParameters></asp:SqlDataSource> I'm hoping the gridview would then display a table with rows for records 1,3,5,7,11. Thanks for any help...
Hi, I am trying to get the login name of a user, trim off some characters, which works fine, convert this to a string variable, which works fine and then use this variable in an sql select parameter. I've tried countless things and am not sure why my variable @NewString is not working in the Select command. If I add a default value I know is present, it works, but it can't seem to pick up the variable value of NewString. It prints out as expected in the response.write statement, but I really need it to connect to the corresponding value in the database. Any ideas are greatly appreciated-code below. Thanks, Liz
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <SCRIPT LANGUAGE="vb" runat="server"> Public Function LoggedOnUser() As StringReturn (Request.ServerVariables("LOGON_USER")) End Function </SCRIPT> <%Dim MyString As String = LoggedOnUser() Dim MyChar As Char() = {"O"c, "N"c, "E"c, ""c}Dim NewString As String = MyString.TrimStart(MyChar)Response.Write("Hello ") Response.Write(NewString) %> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:pboConnectionString %>" SelectCommand="SELECT [LastName], [FirstName], [logon] FROM [Phonebook] WHERE ([logon] = @NewString)"> <SelectParameters> <asp:Parameter DefaultValue="" Name="NewString" Type="String" /> </SelectParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" /> <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" /> <asp:BoundField DataField="logon" HeaderText="logon" SortExpression="logon" /> </Columns></asp:GridView> </asp:Content>
Please can someone provide an overview of how to select all records in the parameter list. I am trying to get an understanding of how this works.
Having a union join with all value is fine, to retrieve the value of 'all'. However, given the data-set there is no 'all' value. From reading the ms course notes, the query syntax is: select from where = (field = @x) or @x = 'all'. How does this syntax work? Does x = all, so all= all = true then returns all records?
I have a problem with SP when passing in Parameters. Basically something like this:
-- Pass 1, 2 or 3 as parameter EXEC SP_mySP 1
-- The SP will do the following SQL Statement SELECT * FROM myTable WHERE ( (If @Parameter1 = 1 then myColumn = 'A' or myColumn = 'B') (If @Parameter1 = 2 then myColumn = 'C') (If @Parameter1 = 3 then myColumn is not null) )
Is it possible and how do I do use a select like query with an adocommand's parameter object?For Example:Instead of this:command.CommandText = "SELECT * FROM Table WHERE field LIKE'%searchString%'This:command.CommandText = "SELECT * FROM Table WHERE field LIKE '%?%'command.Parameters.Append(command.CreateParameter ....Thanks
Which is more efficientWhere NonindexedColumn=x and IndexedColumn=yorWhere IndexedColumn=y and NonindexedColumn=xor does matter? Will the optimiser work it out?(I'm building the SQL string on the fly in the fron-end)
Hy , I'he made a stored procedure with 1 parameter @cTableName and I want to return data from that table: select * from @cTableName , that is all. But it does not work. When I execute the stored procedurere I want to send the name of the table : execute MySP "MyTable". Is it possible? Thank you!
I'm not sure if parameters is the correct solution, but it's all I can think of. I'm trying to use a "template" report with a graphic logo and some other standard layout to provide all my subreports with the same look. On the "default" subreport, I intend to have links to the other subreports, but I can't find a way to dynamically change the subreport shown by the Subreport item.
I have several databases on the same server that have the same table structures within them. Call them
Server.A Server.B Server.C ...etc.
I have designed a report that works in one database, say "A". I would like to add a parameter box to the report giving the user the ability to select which database to run the report in. I'm not sure if this is possible.
There may be more complex ways to handle this, say, with dynamic SQL or by building a large UNION of select statements across the various databases. But I figured I might ask for a simple solution first. :-)