|
Hello
I have a datacolumn that uses an expression to sum other columns, for example i have 3 datacolumns: count1, count2 and count3.
A 4th column "total" uses the expression:
"IsNull([count1],0) + IsNull([count2],0) + IsNull([count3],0)"
Which works fine if any one column value in the row is null. However if all 3 columns have null values, the 4th column will be 0. I want it to be null. See example below.
|count1|count2|count3|total|
| 3| 2| 5| 10|
| 12| | 3| 15|
| | | | 0|
for that last row i would like the total value to be blank rather than 0. How can I achieve that in the expression?
thanks
Yann
|
|
|
|
|
I found the solution
expression should be:
IIF(IsNull(Count1, -1) = -1 and IsNull(Count2, -1) = -1 and IsNull(Count3, -1) = -1, null, IsNull([count1],0) + IsNull([count2],0) + IsNull([count3],0))"
the first part of the IIF statement checks that all 3 count columns are null and returns -1 if they are. If all three conditions are true then the expression evaluates to null. Otherwise it totals up the value.
Yann
|
|
|
|
|
There is a much more simple way to do this. Do your math, and if it equals 0, set the last column to DBNull.Value
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hi,
I have a variable which contains file path called filename and I use this variable to start a process like this: Process proc = Process.Start(filename); If I pass path to a text file then everything work well, but if I create a shortcut for that text file and use it to start a new process, the return value is null. Why does it happen? Apart from that for some executable files the return value is also null. I've checked msdn and according to it null is returned when there already exists same process but it's not the case.
How can I retrieve the process started in this way if the return value is null? Do I have to use winapi?
Thanks
|
|
|
|
|
Not every process returns a value either.
Launching a shortcut just doesn't return a value. You can launch the .EXE, or whatever document, directly and get the return value (if there is one!), but launching through a shortcut drops the return value.
There is no way to retrieve the return value if the one you get back is null .
|
|
|
|
|
I've developed a pretty robust app as one of my first projects. It's a windows app in C#. I'd like to know a little more about how Visual Studio compiles everything, and what all these resource files are..etc. I guess I expected everything to just compile into a single executable. (I'm used to console applications) .. What files are required, and what files are simply there for debugging? What's an Application Manifest file? and a Program debug database? Why are my output files in a funky three extention format? (ex. project.vshost.exe.config) etc.. Any links to resources would be helpful. Thanks everyone.
|
|
|
|
|
|
i am working in MS Access...........when i put a command button on Access form and go to the buildEvent......code builder..........a VB file opens....... i have no idea of VB how can i change settings so that i can code in C#
|
|
|
|
|
You can't. Access uses VBA (Visual Basic for Applications), not C#, to write code.
|
|
|
|
|
what you need to do is create a project in C# and connect to access the same way you would any other ODBC compatible database. There're tons of examples if you google on it.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop.
-- Matthew Faithfull
|
|
|
|
|
how i can validate rdf's xmlns in c#
i.e.
<rdf:rdf xmlns:rdf = "http://www.here.com/why_the_how/rdf"
xmlns:rdfs = "http://www.there.com/how_the_why/schema"
xmlns:ex = "http://www.my.fake/animals">
here what i write so far:
if (output != "" && Regex.Match(output, "<[' ']*['\n']*[' ']*[a-z0-9]+[' ']*:[' ']*rdf[' ']*['\n']*[' ']*[xmlns[' ']*:[' ']*[a-z0-9]+[' ']*['\n']*[' ']*=[' ']*['\n']*[' ']*\"http://www.[a-z0-9]+.[a-z0-9]+[[/]*[a-z0-9]*[[_]*[a-z0-9]+]*[/[a-z0-9]*]*]*\"[' ']*['\n']*[' ']*]*>").Success)
but when duplicate an xmlns it say it is not valid
|
|
|
|
|
I didn't study profoundly your ex. pattern, but I think you should you some method as string.Split or something for each xmlns or http that appears in your string.
Shimi
|
|
|
|
|
for a reason i need it in regex
thanks anyway
casue i'm the man withno lose
|
|
|
|
|
I have a windows service running as LOCAL SYSTEM, I need to get the login name of the current user, I have tried WindowsIdentity.GetCurrent().Name and Environment.UserName but they return NT AUTHORITY/SYSTEM which is the name the windows service is running as. Can anyone tell me how to get the login name of the current user. Any help will be GREATLY appreciated..
|
|
|
|
|
Lash20 wrote: I have a windows service running as LOCAL SYSTEM, I need to get the login name of the current user, I have tried WindowsIdentity.GetCurrent().Name and Environment.UserName but they return NT AUTHORITY/SYSTEM which is the name the windows service is running as. Can anyone tell me how to get the login name of the current user. Any help will be GREATLY appreciated..
This is the method I use to do what you are talking about. It does what you were trying to do with WindowsIdentity.GetCurrent().Name . I would be willing to bet that it isn't working because the process you are calling from is a service running on local system. Run it from a windows process and I bet it works.
public static string getCurrentUsernameAndDomain()
{
WindowsIdentity user = WindowsIdentity.GetCurrent();
return user.Name;
}
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hello everyone, If you have time, I need some suggestions.
I am making a mileage calculator, it is a project I thought up for me to gain some c# coding skills. Anyway, my dilemma is as follows.
I have a form with 6 combo boxes, one is a "START" and the other 5 are optional "ENDING" routes. Basically, someone can select "Indiana" on the first combo box and select "Akron" on one of the others, hit the calculate button and it will tell the mileage.
I have a DataTable set up with 3 columns "FROM|DEST|DIST" so it would be like
"Indiana" "Akron" 120
"Indiana" "Kalamazoo" 211
"Kalamazoo" "Phoenix" 1100
My problem is when i populate my first combo box with the "From" category, I get tons of duplicates, as there are many names in the from category that are the same. How Im adding data is below (Yes its being hardcoded, I dont know enough about databases to set one up yet)
xDt_List = new DataTable();<br />
<br />
xDt_List.Columns.Add("Start", typeof(string));<br />
xDt_List.Columns.Add("Dest", typeof(string));<br />
xDt_List.Columns.Add("Dist", typeof(short));<br />
<br />
DataRow xDr_Row = xDt_List.NewRow();<br />
<br />
xDr_Row["Start"] = "Indianapolis";<br />
xDr_Row["Dest"] = "Kalamazoo";<br />
xDr_Row["Dist"] = 211;<br />
xDt_List.Rows.Add(xDr_Row);<br />
<br />
xDr_Row = xDt_List.NewRow();
and so on and so forth...
Thank you for *any* suggestions on how I could make this a little more effecient ect.
modified on Tuesday, January 15, 2008 11:16:32 AM
|
|
|
|
|
DataTable.DefaultView.RowFilter = "Start DISTINCT";
ComboBox.DataSource = DataTable.DefaultView;
only two letters away from being an asset
|
|
|
|
|
I need to write an application in c# 2003 that is a window service that hosts a remoting object of type singelton.
Is there anyway to notify the service (the host) when a message from the client arrives to the remote object
sample code will be greate help
than
|
|
|
|
|
poqeqw wrote: I need to write an application in c# 2003 that is a window service that hosts a remoting object of type singelton.
They hide that information in the documntation[^]
|
|
|
|
|
How to change the icon of custome Components.
I am able to change the icon in toolbox but while draggin the control
into form default icon is coming !
Any idea ??
Thanks in advance
|
|
|
|
|
Can you explain what you mean by "while draggin the control into form default icon is coming !"
I don't know what that means.
|
|
|
|
|
if you think about ColorDialog Box , it is a custom control, now in tool box it has a icon and while dragging that from tool box the icon are same , but i have build a custome componets and in toolbox i am getting icon what ever i gave but while draggin default (circle) icon is coming !!!
|
|
|
|
|
Hi. Im sort of a newbie in C# but i have a task for my graduation subject to create an application - a game or some sort of a quiz. Anyway, the application itself is not a problem. The problem occurs at the end of the game, because i had an idea that the player will get a diploma at the end of the game.
The diploma should look like this: The background is an old scipt (the game occurs around the 16th century) and on this script is some written text. There should also be an option to print out the players name.
So, please explain, if you can, if it's possible to edit an .doc file with some objects already present in the file (text, background) and add some text (the players name) in the middle of the page.
I know that printing some text, directly from a C# application is possible, but a file? and before printing, editing this file?
Is it complicated? If you could please add some code at your reply.
Thanks in advance,
Max
ps: sorry for my bad english.
Força Barça!
|
|
|
|
|
I think the easiest way to do this with Word would be to use the VSTO[^].
However, a better approach might be to investigate the PrintDocument[^] and related classes[^] so you can roll your own solution.
|
|
|
|
|
Thank you for your fast answer. I will check those things out... but can anyone gime me an particular example? something small, just to see how it would look like. To read the file, edit the file and print it out.
Anyway, i will take a look myself at those links and try to find my own solution, but i doubt that it will come out soon my deadline is in a month.
Bye,
Max
Força Barça!
|
|
|
|