How can I use ForEach<T> activity to look each DataRow in DataTable.Rows?
Seems that DataTable.Rows is DataRowCollection, which does not support IEnumerable.
View Complete Post
I have a following scenario -
A use selects criterias from a webform (C#) - a result is then returned from the sql. Say, to start, there are 2000 data returned from the sql and are stored in a dataset.
Now, the user wants to choose a number of drops (up to 6) - with the number of drops selected, they can enter their own quantity in each box. So, they can divide the 2000 records into 6 different drops. With each drop, there is campaigncode created based on the mail date and the job number they provide.
So, now i have the 2000 records in a dataset. What i want to do is loop through the gridview where the user fill out the quantity depending on the number of drops (for ex: if they say 3 drops, then there will be 3 rows in gridview with 3 quantity box to fill).
In the loop, I am getting the quantity, dropdate and the job number. The Campaigncode is created as well. Then, i am looping through the datarow in the dataset; updating the Campaign Code column with the CampaignCode for the number of records thats set in a loop. It works but the Campaign Code is not populated for the next set of records.
Here is the code:
private void AddAEFiels()
int _totalCount = 0;
string job = null;
foreach (GridViewRow row in gvDropDates.
Everytime I want set a datasource (also if I create a new one with an click on the drop down) I got the following error message from the container.
TITLE: For each schema rowset
The new connection, LocalHost.ReportServer, is not an OLE DB connection so it can not be used by the schema rowset enumerator and, therefore, will not be added to the connections list.
But if I generate a OLE DB connection manually it does not appear in the dropdown list of the container. Does anybody know what I have to do in that case?
I'm trying to figure out how to update multiple rows in my Directory table, when a user changes their Street Number or Street Name in their profile. They can add multiple users to a directory and each user they add to the directory has this primary users UserId in it. So if the primary user changes their address, I want it to update the address for all the users they listed in the directory as well. I'm adding this to the On_Click in the Code Behind, so when they click to update their profile, it fires this function as well.
This code may be way off, but here's what I have right now:
//Update directory user addresses for this account, if profile address has changed
if ((currentStreetNumber != creatingStreetNumber) || (currentStreetName != creatingStreetName))
string myDirectoryConnection = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlDataAdapter cmd2 = new SqlDataAdapter("Update Directory SET [StreetNumber] = @StreetNumber, [StreetName = @StreetName] WHERE [UserId] = @UserId", myDirectoryConnection);
Hi I pull data from Database to be in a data table called dtDatatable after which specified that to the gridview.
ElseIf Not dtTransaction Is Nothing Then
gvTransaction.DataSource = dtTransaction
i am making a web application in which at one time i have to insert the vales into three table..
first table will generate scope_identity,
then in foreach loop values are inserted in 2nd table with ref of scope identity
and then same with the 3rd table
problem is i dont know how to put transaction in foreach loop......
please help me.......
here is my dummy code please help me....
SqlConnection con = new SqlConnection("server=xxxx;uid=xxxx;password=xxx;database=xxxx;connect timeout=3600");
SqlCommand cmd = new SqlCommand("insert into test(a,b,c,d,e,f,g,h) values ('a','b','c','d','e','f','g','h');select scope_identity()", con);
decimal idd = (decimal)cmd.ExecuteScalar();
for (int i = 0; i < 15; i++)
SqlCommand cmd1 = new SqlCommand("insert into test1(a,b,c,d,e,f,g,h) values ('"+idd.ToString()+"','b','c','d','e','f','g','h')", con);
for (int i = 0; i < 15; i++)
SqlCommand cmd2 = new SqlCommand("insert into test2(a,b,c,d,e,f,g,h) values ('&
DataTable result = GetDataSetByQuery(query).TablesIList<string> li=new IList<string>();