|
Ok. Then it is difficult to find which item is missing...?
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
well I am sorry, but are you a programmer?
if you want that then you can find all rows one by one and see what you are missing. Or you can compare the results again for your criteria and see what you are missing.
-----
|
|
|
|
|
YES YES YES !!!!
I am a programmer , and facing problems so ask this question.
Why are you asking that...? Any prob...?
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
well, sorry if you are offended. but normally people ask for guidance/hints in the forums and you can't even think/do this simple thing after you have all the code to find the results... all code was there and now you just had to think a very little to do your task but you posted the next question without thinking ... if you really want to learn then please spend some time in making your logic on paper before start coding..
-----
|
|
|
|
|
Yes, sir you are right.
Actually what is happening, I am having more than 23,000 items and I don't want to traverse. I search a lot but no good solution is found. And if I am having 10 records in a new order then I have to traverse through the 23thousand records so I ask a solution.
The solution you provide is good but I unable to understand how I can found the unmatched items...?
At the end of all.... I am very very sorry if I hurt you any way.
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
well without going in detail here is the quick fix for you:
<br />
<br />
bool testMatched, test1Matched, test2Matched, test4Matched;<br />
testMatched = false;<br />
test1Matched = false;<br />
test2Matched = false;<br />
test4Matched = false;<br />
<br />
foundRows = datatable.Select("itemName='test' or itemName='test1' or itemName='test2' or itemName='test4'");<br />
<br />
if(foundRows.Length > 0)<br />
{<br />
for(int i=0; i<foundRows.Length; i++)<br />
{<br />
switch(foundRows[i]["itemName"])<br />
{<br />
case "test":<br />
testMatched = true;<br />
break;<br />
case "test1":<br />
test1Matched = true;<br />
break;<br />
case "test2":<br />
test2Matched = true;<br />
break;<br />
case "test4":<br />
test4Matched = true;<br />
break;<br />
}<br />
}<br />
}<br />
<br />
if(!testMatched)<br />
Response.Write("Test did not found");<br />
hope this will help you
-----
|
|
|
|
|
Thanks for your reply sir...
I also create a logic can you check it for me?
//Filling the datatable
dataTableItems....
///Create the generic object
List<string> listNoOfItems = new List<string>();
//Adding the search item into the list
listNoOfItems.Add("Item1");
listNoOfItems.Add("Item2");
for (int listIndex = 0; listIndex <= listNoOfItems.Count - 1; listIndex++)
{
DataRow[] foundRows;
//Finding the rows....
foundRows = dataTableItems.Select("ItemName = '" + listNoOfItems[listIndex] + "'");
if (foundRows.Length <= 0)
{
MessageBox.Show("Not found " + listNoOfItems[listIndex]);
}
else
{
MessageBox.Show("Found " + foundRows[0]["ItemName"].ToString());
}
}
Will this code is OK...?
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Why not create separate DataRow arrays for each expression if you want to segregate them, or use OR in your select string if you want to group them all together?
For example (using expresion segregation):
DataTable dt = ...(your data table definition)
DataRow[] drMobile = dt.Select("ItemName = 'mobile'");
DataRow[] drTV = dt.Select("ItemName = 'tv'");
DataRow[] drRadio = dt.Select("ItemName = 'radio'");
DataRow[] drComputer = dt.Select("ItemName = 'computer'");
or (grouping them all together):
DataTable dt = ...(your data table definition)
DataRow[] drows = dt.Select("ItemName = 'mobile' OR ItemName = 'tv' OR ItemName = 'radio' OR ItemName = 'computer'");
By the way, I don't recommend using ArrayList... instead, use Generics, for example, instead of using:
ArrayList al = new ArrayList();
string v1 = "some text";
string v2 = "some more text";
string v3 = "even more text";
// you get the point...
al.Add(v1);
al.Add(v2);
al.Add(v3);
// etc.
and then casting the content back to a string variable:
string v1Str = (string)al[0];
...
Use Generics:
List<string> al = new List<string>();
string v1 = "some text";
string v2 = "some more text";
string v3 = "even more text";
al.Add(v1);
al.Add(v2);
al.Add(v3);
// etc.
now, you don't have to cast the values back to a string when you retrieve them:
string v1Str = al[0];
string v2Str = al[1];
...
Depending on what you are storing in the ArrayList, the cast operation can be very costly in terms of performance.
Microsoft doesn't recommend using the ArrayList in .NET 2.0 and higher.
-- modified at 22:03 Sunday 18th November, 2007
|
|
|
|
|
Thank you very much for your suggestion. Actually I have a data table with 10thousand records and now I have 4-5 items and I want to found any of item is missing or not ..? for that I have to traverse through data table, So I use array list which is having contains method which make traversing fast.
Please give a good solution to resolve this issue.
Also thanks for the guidance of using list instead of array list.
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Hello, I've recently found stranged things could happen when I set up an event handler for the HandleCreated Event in C# windows controls.
So what is HandleCreated Event? When will it be raised? Thanks in advance.
|
|
|
|
|
Well, a handle is pretty much just a pointer to the object, and can be used for a variety of things. For example say you create a bitmap and draw a picture onto it, and you then wanted to pass this image to another form, instead of passing the whole image, you could just pass the handle and then use Bitmap.FromHandle().
But, i would have thought that the handle would be created at the same time as the instance of an object, unless you can somehow make more. I'm not so savvy with handles. If you check the MSDN documentation you should find the answers you seek.
EDIT: Nevermind, MSDN doesn't help much. It just says that it fires when a handle is created (wow, really?!) and that it is useful for debugging.
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
Thanks for your helpful explanation.
|
|
|
|
|
Hello All,
I know there are many on this topic, but after looking at all the articles, i felt lost
and hence posting it here for quick help.
I have a datagridview with columns Task and Status. When the grid is displayed I want the user to select the Status from the combo box in the cell. How do i do this?
My data for the grid is filled up from an Xml.
Please help!
Thanks
D
|
|
|
|
|
Hi,
protected void dgList_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList ddl = (DropDownList)e.Item.FindControl("ddlStatus");
ddl.SelectedValue = e.Item.Cells[2].Text;
}
}
I hope this helps
"Good Thing Goes With Good People..."
|
|
|
|
|
|
The best RegEx book is the Mastering Regular Expressions book from O'Reilly. You should also download Expresso, a cool app for playing with regex.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Can someone please direct me to some snippet of code that will do the following:
We want to allow our users to upload audio files - we'd like to not limit the format to a specific type (mp3, aud, wav, etc.) but accept all 'reasonable' audio files ... is there a 'generic' routine that can validate that the file being uploaded is indeed an audio file? We can check to see if the extension is acceptable, but that wouldn't prevent a prankster from changing the extension of a non-audio file ... also, what would be the most efficient storage format of audio and can the routine convert it to that format (this would help us control the size of the file uploaded to be within reasonable limits)? Do we have to check for specific file headers or is there a function similar to System.Drawing.Bitmap?
Your assistance is greatly appreciated.
Thx,
TheGAPnoid
|
|
|
|
|
Try reading the first few bytes of the file, and see if it matches up with the extension of the file.
MP3's for example, will probably start with their ID3 tag, so the first three bytes would be:
I D 3
49 44 43
WMA start with their tag, which seems to start with:
0 & ²
30 26 B2
So, you could gather a small database of the headers of the filetypes. And compare the first few bytes of the uploaded file, to the set of bytes you already have.
If you get a file with extension: mp3 and it starts with something other than 49 44 43, you can just say that the extension does not match the filetype. Though you'd have to investigate this further. Im not sure what an mp3 starts with if it has no tag (can you get an mp3 without an ID3 tag?)
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
Well ...an hour passed and I already have another question.
I have the data from a database in a data grid, except the id.
I want to know how can i take the id into a variable if a know the other fields of the row.
To understand exactly:
first column is the name, second column is the job;
I have the name and the job and i wanna find the ID and put it in a variable.
|
|
|
|
|
why don't you load the ID at the same time you are loading other fields and keep it either in datakeynames or in a hidden column of the datagrid
-----
|
|
|
|
|
Hi,
I try to pass two strings from a form to another.
in the first form the strings are stored in a data grid.
I've already retrieved the values fro the grid and i have 2 strings value1 and value 2.
how can i pass them from form 1 to form 2 and store them in two different text boxes in form 2?
Thanks!
|
|
|
|
|
Steauaclau,
There are several ways to do it...
1. Create public static string firstString and reference it by the class name.
public class Form1 : Form
{
public static string firstString
....
}
public class Form2 : Form
{
Form2_OnLoad()
{
tbxStringValue.Text = Form1.firstString;
}
....
}
2. If one form calls the other, it could use a constructor to pass the value in.
Hope this helps.
Hogan
|
|
|
|
|
snorkie wrote: public class Form1 : Form
{
public static string firstString
....
}
Why is the field public. This is not a valid time to make a field on a class public. It breaks the rules of encapsulation (one of the tenets of Object Orientation)
For more information about why making fields public is a bad idea please read:
* Why make fields in a class private, why not make them public?[^]
*The public fields debate again[^]
Also, you make it static. Why? What purpose does that serve? You have some data in controls which reside in instance fields and then you want to transfer it to a static field! Why?
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
I agree with you that it isn't the best approach, and I will read the articles, but I wanted to give a quick and dirty answer to the issue at hand. Probably a bad idea to suggest quick and dirty...
Thanks for the info!
Hogan
|
|
|
|
|