hi Im sending strings to a listbox,
How do i get a count of a specific string,
Listbox test = new Listbox();
if (sEtag[0] == 'E' || sEtag == "F001" || sEtag == "F000"||sEtag=="A083")
{
test.Items.Add(sEtag.ToString());
}
how do i get the count of one of those four strings from the listbox?
Loading
David SmithPosted Mar 6, 2010, 2:44 PM
In my case it was something like this
TRANSFORM Count(Database.[Description]) AS CountOfEDescription
SELECT Database.[OpTimeStamp], OpDatabase.[TestRuns], Count(OpDatabase.[EDescription]) AS [Total Of EDescription]
FROM Database
GROUP BY Database.[TimeStamp], OpDatabase.[TestRuns]
PIVOT Database.[tag];
8. go back to your c# sharp code and paste this in the query window below and hit the red exclamation point on the menu toolbar in visual studio
afterwards rebuild your solution.
9.Last step is to create your a second datagridview, dataset, and tableadapter, and fill your data set you, you will now have you a datagridview with records from your raw data table datagridview1 . I hope this help someone out. Let me know if you need the instructions to complete of creating the dataset, table adapter, and datagridview.
10.Keeping in mind the way I did it , by creating a cross table query Every time I send data to my raw datatable I will have record count of anything new that occur. So if you delete the data out of the data table the datagridview record count is going to be deleted. I love this way.
David SmithPosted Mar 6, 2010, 2:42 PM
2. click on the green plus sign. and add your .mdb. In my case its my raw data table
that we created early in above replys . The basically is going to contain all the tables you created in access.
3. go to the menu tool bar and go to data and select new query.
4. double click you raw data table.
5. go back to ms access and double click on your new cross table which contains the record count
6. go to view on your menu and select SQL View.
David SmithPosted Mar 6, 2010, 2:05 PM
9. the next option is to choose the columns that you want from your raw data table or table of your choice to be rows.
In my case I chose my optimestamp , and my testruns. now my 2columns are going to be rows. click next.
10. the next screen takes you to the option asking you which which field you want from the raw data table or table of your choice from above
to be a row headings of fields. In my case i chose my errors, because i want to get a record count of how many errors occured per test run. click next
11. On next screen you choose the function you to choose, you have many options count, min, max, average, etc..... In my case I wanted to get a count of how
many errors occured so i chose count. click next
12. Next screen , Name your cross table, then select view query and finish. Im going to give the c sharp instructions in the next reply
David SmithPosted Mar 6, 2010, 2:04 PM
2. Go to the Create Tab , And Select Table.
3. Right on the table you just created and select design view.
4. In design view create you a number fields upon your choice.
5. Go back to the Create Tab and select QueryWizard
6. Once you selected Query Wizard select Cross tab query wizard. hit OK.
7. In the cross tab query wizard you have the option to choose the tables you have already created and re design
your new table view how you want it to be. In my case I wanted to choose certain columns from my raw data table
and make all the data thats under a certain column now be a column header or field. In other works take all the current
cells under a column of your choice and make them fields. In my case i chose my raw data table.
David SmithPosted Mar 6, 2010, 12:56 PM
Hi guys i found a effective way since im dealing mdb files.
Ok to give you a overview of what im doing , basically im pulling raw data from a text file and sending it to a mdf file to a datagridview.
From there I create a connection using oledb and send my entire datagridview to MS Access.
The problem that i was having was simply finding a way to get a datagridview record count or sending my raw data to a listbox and simply counting how many times each item occur per test run.
Do not get me wrong ,I got it to work that way, But doing it that way for my situation was not that effective because of new errors that may occur.
To me the most effective way is to create you a second table in MS access aside from you from raw data table.
and do a simply create a query . Im going to post my exact instructions below in the next reply box. Hopefully this helps someone
David SmithPosted Mar 6, 2010, 12:53 PM
Ok to give you a overview of what im doing , basically im pulling raw data from a text file and sending it to a mdf file to a datagridview.
From there I create a connection using oledb and send my entire datagridview to MS Access.
The that i was having was simply finding a way to get a datagridview record count or sending my raw data to a listbox and simply counting how many times each item occur per test run.
Do not get me I got it to work that way, But doing it that way for my situation that effective because of new errors that may occur.
To me the most effective way is to create you a second table in MS access aside from you from raw data table.
and do a simply create a query . Im going to post my exact instructions below in the next reply box. Hopefully this helps someone
kiran kumarPosted Mar 5, 2010, 5:04 AM
MARK THE ANSWER IF IT HELPS YOU
David SmithPosted Mar 5, 2010, 12:45 AM
can you show me a sample?
and can you show me a sample with dictionary idea
David SmithPosted Mar 5, 2010, 12:36 AM
Amit ChoudharyPosted Mar 5, 2010, 12:31 AM
in below line. I'm counting the length of individual and your individual is identified by test.Item[i] using indexes by for loop.
int len=test.Items[i].ToString().length;
inside the loop you'll have length of each string one by one as loop will run.
and you can use it as per your requirement you can create an array of lengths or best will be the dictionary collection that can store string and length together.
David SmithPosted Mar 5, 2010, 12:04 AM
you are only counting the total of all items , i want to choose indivuals
Amit ChoudharyPosted Mar 4, 2010, 11:48 PM
try below code:
for(int i=0;i
int len=test.Items[i].ToString().length;
}
Please mark the answer if it helps you.