|
thanks for ur reply,
here is my code....
my datatable(named as sortedDataTable) has columns as in my previous message... and i use iequalitycomparer as below
IEnumerable<DataRow> drdistinct = sortedDataTable.AsEnumerable().Distinct(new MyDataRowComparer());
in my iequalitycomparer class i have these codes...
<pre>
class MyDataRowComparer : IEqualityComparer<DataRow>
{
public MyDataRowComparer()
{
}
public bool Equals(DataRow x, DataRow y)
{
if (x.Field<string>("Fam.") == y.Field<string>("Fam.") && x.Field<string>("Description") == y.Field<string>("Description"))
{
x["Component"] = Convert.ToInt16(x["Component"]) + 1;
x["Quantity"] = Convert.ToDouble(x["Quantity"]) + Convert.ToDouble(y["Quantity"]);
//y.Delete();
return true;
}
else
return false;
}
public int GetHashCode(DataRow obj)
{
int a = obj.Field<string>("Fam.").GetHashCode();
int b = obj.Field<string>("Description").GetHashCode();
// obj["Component"] = Convert.ToInt16(obj["Component"]) + 1;
//x["Quantity"] = Convert.ToDouble(x["Quantity"]) + Convert.ToDouble(y["Quantity"]);
return a + b;
} </pre>
these code, works fine and it returns me only the distinct rows, but this gethashcode method adds the first row and then compares it with subsequent rows, so if i apend column values in equals method as in above, it doesnt affect the datatable as it adds the row in the begining itself..
|
|
|
|
|
It seems to me that your problem would be better solved by a properly constructed Stored Procedure in your database.
I am not particularly good at SQL so if this idea appeals, you might get a better solution in the General Database Forum.
However, something like:
SELECT
Fam., Description, etc.,
SUM(Component) AS "Component Total",
SUM(Quantity) AS "Quantity Total"
FROM
your_table
GROUP BY
Fam., Description
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
im not using database. I have one datatable which has all rows (duplicate rows)... I want to create another datatable which contains distinct rows and while getting the distinct rows, i have to add "component" column value.
|
|
|
|
|
The same principle applies. It will be far easier to do on the original data than from a datatable. So if you are not using a database, how are you filling the datatable? What is your data source if not a database?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hi...
am using vb.net + sql 20000, now i have to install sql server then create the database and install t application, by following these process only i would be able to run t application. i wanna know will i be able to use my application with out installing sqlserver (ie by using msde can i create db) and how to create an installation package for the above
|
|
|
|
|
Ageesh wrote: am using vb.net + sql 20000
Well first of all, try using a database engine that isn't from the future .... lol
Ok all jokes aside,
You are going to have to use a custom action during the installation to determine if the database exists or if you should create it.
This should get you started A Custom Action for Deploying a Visual Studio 2005 Add-in[^]
As far as installing without SQL Server, thats fine but your application has to account for the lack of a SQL Server.
Normally there should be a SQL Server on the network that you can connect to, you would have to get that information from the user either during installation or the first time the app is run.
MSDN Context Properties[^]
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
I m trying to import unmanage dll "pcrsrv32.dll" using following method in .NET project
DllImport("pcrsrv32.dll")> _
Function PCRSInitSrv(ByVal appName$, ByVal iniFile$) As Long
End Function
this dll is product of PC*Miler|Rail-connect not microsoft so its not successully imported becoz
on successfull PCRSInitSrv method should return 0 but in my project it return non zero value.
Plz help me is there some other method to use this dll
|
|
|
|
|
Well, you're not getting a runtime exception, which means that you indeed are correctly importing the function. That being said, PCRSInitSrv returns a non-zero error code if it fails; you should use PCRSGetErrorString (another DLL-provided function) to figure out what the error is. This way, you might have a better chance of diagnosing your problem
Adam Maras | Software Developer
Microsoft Certified Professional Developer
|
|
|
|
|
Do you not think this question would be better asked of the support team at www.alk.com? As they wrote the application, it seems likely that they will have specialist knowledge that will help.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
I haven't tested it, but this seems more appropriate:
DllImport("pcrsrv32.dll")> _
Public Shared Function PCRSInitSrv(ByVal appName$ as String, ByVal iniFile$ as String) As Long
End Function
You need both Public and Shared; and IMO you should provide type information on all parameters.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I would have suggested the same, but the fact that the DLL's function is executing and returning a value (an HRESULT, to be exact) means P/Invoke is managing to bind the function correctly. Yeah, it's not the greatest practice, but it works...
Adam Maras | Software Developer
Microsoft Certified Professional Developer
|
|
|
|
|
Hello!
I am writing a button generator application in where you type in a number within a text box and click the generate button in where it will randomly create buttons in different locations within the application.
I am also trying to make it so that an action is performed when i click these buttons, but i cant figure out how to do it. Here is my code so far.
FORM CODE:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim newInstance As New myButton
End Sub
End Class
BUTTON CODE:
Public Class myButton
Public Sub New()
Dim newButton As New Windows.Forms.Button
Form1.Controls.Add(newButton)
End Sub
Friend WithEvents newButton As Windows.Forms.Button
Public Sub mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles newButton.Click
MsgBox("hi")
End Sub
End Class
As you can see from the code, it should show a message box when each instance of a button gets clicked, but its not working. I'm not sure if im doing this the right way or not, can someone please help me with this because i cannot find anything on the internet about it.
Thankyou.
|
|
|
|
|
Hi,
in your code
[1] Public Class myButton
[2] Public Sub New()
[3] Dim newButton As New Windows.Forms.Button
[4] Form1.Controls.Add(newButton)
[5] End Sub
[6] Friend WithEvents newButton As Windows.Forms.Button
[7] Public Sub mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles newButton.Click
[8] MsgBox("hi")
[9] End Sub
[10] End Class
Class myButton represents a button, i.e. ONE button, however I see two declarations: lines [3] and [6].
The "Handles newButton.Click" in [7] refers to the newButton in [6] which is and remains Nothing.
The New Button in [3] ends up in the local variable newButton, which you add to the Form, but which is unrelated to the one in [6].
The solution should be obvious.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks for the help, i've got it working now!
Sorry if that seemed a stupid question
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I was trying to build a program to clean temp, unwanted, junk files from applications like chat clients, browsers, p2p applications, on windows platform. Can anyone please provide some guidance on how to proceed.
|
|
|
|
|
1) Find the folder
2) Delete the files
What more do you want?
only two letters away from being an asset
|
|
|
|
|
Hi,
1. use Directory.GetFiles();
2. use File.Delete();
3. do not use Process.Start("cmd.exe", "/C del *.*");
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: 3. do not use Process.Start("cmd.exe", "/C del *.*");
How about Process.Start("cmd.exe", "/c format c: /fs:ntfs") ?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Sorry, I forgot that one. I think it belongs in the "do not use" category.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: I think it belongs in the "do not use" category.
You only think that. We'll leave that in the toolbox, and let the OP try it out if he can't come up with any alternative; as long as he lets me know what his application is called so I can avoid downloading it.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I would like to be able to join math variables. What I mean with this is that, for example, the following can be joined (I don't know if this is actually called joining):
2x^2 - 5x^2 + 2x + 3x - 5 + 6
join to (is equal to):
-3x^2 + 5x + 1
Is there a library or does someone have a code snippet for such actions? If you have a hint or an easy trick, also please tell me. Thanks.
|
|
|
|
|
The process you're talking about is called simplifying. I would assume it's done by going through each element (where element 0 is 2x2, element 1 is -5x2, etc) and making a note of each unique index (the power). When you encounter an index that's occurred before, add the current element to the unique element that's got the matching index and move on.
After that you just need to display it. With this, you just iterate through the list of unique elements and print them.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Thanks very much for your suggestion. It's a great idea of performing the action, however, I tried using Regex to make an ordered list (array) of all items:
+2x^2
-5x^2
etc.
The expression is ([+-])(.*)x\^2
It works well, but now I have to simplify them - I will try doing so.
|
|
|
|
|
Just a note regarding your Regex. You're assuming that the letter following the number is always x, that there is only one such letter, and that the power it's raised to is always 2. If you move on to more advanced equations, like 2xy<sup>4</sup> - 3x + 4xy<sup>4</sup> , then you'll have to alter it.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|