I'm using a sql data source and I need to perform a foreach query. I have a collection of id's and I need to hit my database (the one available via sql data source) for each of the id's in the collection. I know that the sql data source returns a data view and it can be coverted to a data table. What's the best way to query a database using the sql data source ojbect for each id in a collection? Here's my code.
How is foreach loop container - foreach ADO enumerator performace in SSIS package compares to use of cursors in stored procedures
Is there any articles comparing them
I understand a lot of factors can affect the performance, however what is expected performance for the foreach ADO enumerator loop for large dataset. What is Microsoft recommendation for that - recommended - not recommended (using large datasets - over million records)
I have no "Foreach File Enumerator" oprtion in the Enumerator Property of the Foreach Loop Component.
I have this enumerator in the c:Program FilesMicrosoft SQL Server90DTSForEachEnumerators folder.
Also I check it in the GAC - it does not here. I try to execute gacutil.exe -iF ForEachFileEnumerator.dll, but it is failed with "Failure adding assembly to the cache: The module was expected to contain an assembly manifest." Seems it is not managed enumerator.
Please help me.
Also information on how to regeister unmanaged enumerators are welcome!
I'm sure this is a simple thing to do, but I'm new to SSIS and trying to catch up fast.
I want to execute a query on the database which will give me a path and a filespec, say:
c:apps estapp1
and
fred*.csv
No problems here.
I then want to feed them into a ForEach loop and interate through all the files matching the filespec at that location. I can't figure this out at all.
Hi Folks,Could someone please enlighten me on the syntax I should be using to create a for-each structure within a Stored Procedure? Here's what I'm trying to do:Run through a "project" table, extracting the columns [id int], [name varchar] of each row, inserting these into the "reporting_table"Then, for each [project id] now in reporting_table, I need to calculate the value of the [total_cost numeric(18,2)] field in order to update it in the reporting_table:Run though the [orders] table (a master table), WHEN [project id] = [project id of current iteration], @totalCost += [orderTotalCost]Insert @totalCost into reporting_table's [total_cost] column.I.E. basically totalling the total cost of all orders in the order table by Project I hope that makes sense? Maybe I'm over complicating it somehow? The reason I'm using a reporting_table is that .NET's built in GridView would be perfect for displaying this type of data, and it's very easy to bind a GridView object directly to a table. Thanks in advance,Ally
Ever since installing SQL Server 2005 SP1, when using the Foreach Loop container in SSIS the Foreach File Enumerator and Foreach Item Enumerator are missing from the Enumerator drop down box. Anyone else seen this issue? and know how to fix it?
Hi, I have a SQLDataSource binding to a GridView and can come to the page either with or without a query string attached: /ProjectManagement/reporting/project.aspx /ProjectManagement/reporting/project.aspx?portfolio=3 When it comes with a query string, I can see in SQL Server profiler it executes and I get all the right data. When it is an empty string, or with no "?portfolio=" on it, it won't even execute against SQL server. Any ideas? <asp:GridView ID="grid" runat="server" Width="600px" ShowHeader="false" AutoGenerateColumns="false" DataSourceID="DSportfolio" AllowSorting = "true" AllowPaging = "true"> <Columns> <asp:TemplateField> <ItemTemplate> ............. </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:SqlDataSource ID="DSportfolio" ConnectionString="<%$ AppSettings:SQLConnection1 %>" SelectCommand="uspSELECT_PROJECT" SelectCommandType="StoredProcedure" runat="server"> <SelectParameters> <asp:QueryStringParameter Name="p_PORTFOLIOID" QueryStringField="portfolio" /> </SelectParameters> </asp:SqlDataSource> Thanks, James
I have set up roles in my asp.net application, have created my various folders and pages and have the login stuff working nicely, inlcuding displaying the logged-in user's name on screen. What I want to do is read that value (displayed via the LoginName control) as a Parameter in a SqlDataSource query which extracts user-specific data from a sql server 2k datasource. Essentially, if the logged-in user's UserName is jbloggs - I would like to be able to read that into my sql query as @UserName or the like. If possible, I am trying to do this via the Visual Studio interface, not as code-behind. Many thanks, Doc Brown.
I am trying to reload an AJAX control without reloading the page. This question may belong under AJAX, but I'm not sure if I'm managing the SqlDataSource correctly. I want to set the SelectCommand to a new SQL statement and refresh the form on the screen. My code is below. It doesn't seem to be working. Do I need to call something else or is this correct and the problem is with that nasty AJAX?SqlDataSource oSqlDataSource1 = (SqlDataSource) oContentPlaceHolder1.FindControl("SqlDataSource1");oSqlDataSource1.SelectCommand = "SELECT * FROM WorkHistory WHERE WorkHistoryID = " + sWorkHistoryID;oSqlDataSource1.Select(DataSourceSelectArguments.Empty);
Hi, I have a little problem with a SqlDataSource. A table in my database has an ID collumn, which is an integer auto-increment. The datasource has a SelectQuery with an [ID] parameter, which it retrieves from the querystring. I want the DataSource to return all rows when no querystring parameter is passed, and when an ID is given via the querystring, a 'WHERE' clause in the SelectQuery would return only certain records. However, suppose I have the following query: SELECT * FROM SomeTable WHERE ([ID] = @ID) When I bind @ID to the QueryString with '*' as DefaultValue, it throws an exception saying it can't convert '*' to a smallint, which makes sense. I haven't got a clue how to solve this, except for using different DataSources based on the presence of the querystring parameter. Any idea's?
Hi all, I was wondering if anyone can help me figure out how to insert a variable into a query using Visual Studio 2005 with the SqlDataSource control. I cant seem to be able to enter a var into the query parameters.
this is my SqlDataSource: <asp: SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:imLookinLikeConnectionString %>" DeleteCommand="DELETE FROM [tblDiaryEntries] WHERE [DiaryEntryID] = @DiaryEntryID" SelectCommand="SELECT tblDiaryEntries.DiaryEntryID, tblDiaryEntries.EntryDate, tblDiaryEntries.Subject, tblDiaryEntries.DiaryEntry, aspnet_Users.UserName FROM tblDiaryEntries INNER JOIN aspnet_Users ON tblDiaryEntries.UserID = aspnet_Users.UserId WHERE UserName=@UserName ORDER BY tblDiaryEntries.EntryDate DESC" UpdateCommand="UPDATE [tblDiaryEntries] SET [DiaryEntry] = @DiaryEntry, [EntryDate] = @EntryDate, [Subject] = @Subject WHERE [DiaryEntryID] = @DiaryEntryID" InsertCommand="INSERT INTO tblDiaryEntries(UserID, EntryDate, Subject, DiaryEntry) VALUES (@UserId, GETDATE(), @Subject, @DiaryEntry)"> <DeleteParameters> <asp: Parameter Name="DiaryEntryID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp: Parameter Name="DiaryEntry" Type="String" /> <asp: Parameter Name="EntryDate" Type="String" /> <asp: Parameter Name="Subject" Type="String" /> <asp: Parameter Name="DiaryEntryID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp: Parameter Name="DiaryEntry" Type="String" /> <asp: Parameter Name="EntryDate" Type="String" /> <asp: Parameter Name="Subject" Type="String" /> <asp: ProfileParameter DefaultValue="Anonymous" Name="UserName" PropertyName="UserName" /> <asp: Parameter Name="UserId" /> </InsertParameters> <SelectParameters> <asp: ProfileParameter DefaultValue="Anonymous" Name="UserName" PropertyName="UserName" /> </SelectParameters> </asp: SqlDataSource> What I want to do is to tell the SqlDataSource that @UserName = this.User.Identity.Name, but I only know how to do that in code-behind, not sure how to insert it into the code above.Any ideas?
...for instance i want to select * from lists where publishdate > todayDate() do i need to include todays date as a selectparameter? can you provide example please?
I am creating a search page for master detail tables. The search criteria is mainly on the header table. However, there is also one criteria which is in detail table, let said product number.In my SqlDataSource, I setup the SQL like this.select fieldA, fieldB, ..., fieldZ from masterTable where (1 = 1)Then, the additional search criteria is appended to the SqlDataSource select command once the user click the search button. If user wants to search product number, the following will be appendedand exists (select 1 from detailTable where pid = masterTable.id and productNo = @productNo)The problem is when I provides both the sub-query criteria and 2 date fields criteria. The page will raise an timeout exception. I don't have any clue on this as I can copy the SQL and run it inside the SQL Server Management Studio. The result come up in a second.Any suggestion on tackling this problem? Thanks!
I've found example code of accessing an SQLDataSource and even have it working in my own code - an example would be Dim datastuff As DataView = CType(srcSoftwareSelected.Select(DataSourceSelectArguments.Empty), DataView) Dim row As DataRow = datastuff.Table.Rows(0) Dim installtype As Integer = row("InstallMethod") Dim install As String = row("Install").ToString Dim notes As String = row("Notes").ToString The above only works on a single row, of course. If I needed more, I know I can loop it.The query in srcSoftwareSelected is something like "SELECT InstallMethod, Install, Notes FROM Software"My problem lies in trying to access the data in a simliar way when I'm using a SELECT COUNT query. Dim datastuff As DataView = CType(srcSoftwareUsage.Select(DataSourceSelectArguments.Empty), DataView) Dim row As DataRow = datastuff.Table.Rows(0) Dim count As Integer = row("rowcnt") The query here is "SELECT COUNT(*) as rowcnt FROM Software"The variable count is 1 every time I query this, no matter what the actual count is. I know I've got to be accessing the incorrect data member in the 2nd query because a gridview tied to srcSoftwareUsage (the SQLDataSource) always displays the correct value. Where am I going wrong here?
I have a query that I created in SqlServer and then merely copied the code to a sqldatasource. They are both connected to the same db, however the sqldatasource query only returns 6 records and when run in SqlServer, it returns 52 rows which is the correct number. Any ideas on what might be causing this? There are no filters on the sqldatasource. It only has that one query. Do they differ in the way they execute sql code? Thanks for any help!
I want to make a sqldatasource to insert data ito a table with values from textfields page. I want to use the sqldatasource programically (not bind it to a formcontrol). I drag a sqldatasource from the toolbox to the design surface and start configuring the datasource. I spesify a custom sql statement, select the "Insert" tab and insert the table I want to store into the builder. Then I select the fields and the values (parameters from tue textfields. I test it with the "Execute query" button and the results is stored in the table. (everything seems ok) I press the "OK" button but both the "Next" and "Finish" buttons are dissabled, o I can not store the query. What is going wrong. Can someone please help me ? Tom Knardahl
hi, i want to execute a finctionX() based on the returned resultset of SQLDataSource. For example, if the SELECT command returns nothing based on a specific search criteria then I want to execute functionX(). Currently, I have a string that displays "No Result" in the GridView in such case. How to catch the resultset of SQLDataSource? -nero
What is the C# code I use to do this? I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.
i am using visual web developer 2005 with SQL Express 2005 with VB as the code behindi have one database and three tables in itfor manipulating each table i am using separate SqlDataSource() is it sufficient to use one SqlDataSource() for manipulating all the three tables ? i am manipulating all the tables in the same page only please help me
I€™m not sure whether a €śForeach€? capability is achievable in SQL; I€™ve examined joins, unions and subqueries but can€™t come up with a solution.
Scenario is 3 related tables: Location, Room, Booking (date and guest name) and what I wish to do is produce a data grid that shows every for each Location and for each room the status on a given day as follows:
Location Room Date Guest Main 1 1/1/06 Jones Main 2 1/1/06 Smith Main 3 null null Annex 1 1/1/06 Bloggs House 1 null null
In psuedo-code what I want to do is
For a given date Show each location for each location show each room for each room show guest (if present) else show null.
I can generate Location and Room OK using LEFT OUTER JOIN but when I introduce the date check it all goes pear shaped in that (obviously) the grid is not populated with nulls in place of the non-existent booking records!
Hi I have created a ForEach loop based on a custom collection of 1 column containing string values (a list of table names). I want to loop thru this and save the row value (Table Name) into a user variable that will then be used to lookup the table name from within my data task, which is inside the loop.
anyone know how to do this?
Thanks Shailen S.
-------------
Found my solution.
The Variable mappings section allows you to define a variable that will hold the contents of the iterator. This will be a user defined variable.
Would like to do a file System task and a data flow for each row in a table.
I use a ForEach container with ADO enumerator set to a rowset variable. The rowset contains all rows from a single table. What I want to do is as in pseudo-code below:
for each row in ADO rowset
varDestination=CurrentRow.col_file_name.value
FileSystemTask.Destination=VarDestination
FilesystemTask.Copy(Source to Destination)(copy excel file from fixed folder to multiple variable folders)
DataFlowtask.Destination=varDestination(Write data to an excel destination Next My problem is that I dont know how to access the values of fileds from my current row in the rowset. Request help and pointers to samples. TIA Kar
Hello everybody. I'm having a problem: As the result of Dataflow task I get a recordset with about 50 columns in it. Now I need to loop through each row in the dataset and make some manipulations with the data in all 50 columns in a single script task. So I need 'em as separate variables. Ofcourse I can make a For Each Loop container with ADO enumerator, and map each column to specific variable. But that's not a very good thing, because if the format changes, i will have to remap everything again (takes a lot of time to remap 50 values)
So is it possible: 1. To map using not index of columns, but there names? 2. To pass actual row into the script task?
I need to simulate cursor-type (groan) behavior in a dataset and am wondering if this is possible in the foreach task. Example - The user has the need to go through the data row-by-row, and if a certain value is missing in row 10 then go back to row 8, grab a value from that row, and plug it in the missing column in row 10. Then move on to row 11.
Is there a way to make the foreach ADO enumerator travel backwards? Is there a way to do this that will not be awfully inefficient? Any suggestions out there would be welcome.
I've advocated for set-based updates, and these simply aren't an option, as each successive row depends on the updates that may have happened above it in the sequence. Unless I hear of any other ideas out there I have to move forward with this sequential type operation.
I need to execute about dozen packages from another package... how do I dynamically pass the dozen package names to the package and execute using foreach loop...?
idea is to store the names of packages in a text file and set the file connection property reading each package names from the text file... in this way I can just configure/edit the text file from time to time, the packages and the units that I want to execute...
I loop through a list of files in a directory and one of the tasks in the container is to validate the xml file against dtd if this succeeds i process the file and the lforeachloop gets the next file. If validation fails i then delete that file,the problem i am having is that whe the xml task fails it stops the whole for each container even though the failparentonfailure is set to false.
How can i get the foreach container to continue to the next file after the xmltask fails (validation) and the file is succesfully deleted?
PS is their away of posting the DTSx screenshot as this might explain it better?