|
I need to know where to check for system status? like messenger 'Away' after say 5 minutes. I need to run code when it goes into such a status, and again when it returns to normal.
marcelw
|
|
|
|
|
I tried to create static classes but failed. I tried something like,
public static class StaticClass
{
public static int start()
{
return 5;
}
}
but it didn't work. I am using .NET framework 1.1. Can anyone help me!
Bikash Rai
|
|
|
|
|
That isn't supported until .NET 2.0
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
In 1.1, static is not an object level modifier. Just define all of your functions as static instead and you'll get the effect you desire.
|
|
|
|
|
And of course, declare the constructor protected or private to prevent the class from being instantiated by clients.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Bikash,
In the 1.1 .NET framework, a static class is a sealed class with a private constructor. I use them all the time.
Your example would look like this:
public sealed class StaticClass {
private const int start = 5;
private StaticClass() {
}
public static int Start {
get { return start; }
}
}
Brian Leach
-- modified at 16:04 Tuesday 25th October, 2005
|
|
|
|
|
I want to know how i can implement push server tech. in client\server application
|
|
|
|
|
I need help on how I can insert data from a csv file into a ms sequal
DB table. Any ideas
|
|
|
|
|
You could look at the BULK INSERT[^] command.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
How can i get the value of the scrollbar in my Richtextbox???.
I have seen an example with api functions!!
But in the .NET Framework 2.0.2 there must be this property!!
Yours sincerely,
Berni
|
|
|
|
|
I am using mock objects in .net 2.0, but it seems like nmock fails completely under 2.0.
Creation of the mocks works fine, but as soon as i try to call a method on my mock instance i get a FatalExecutionEngineError.
Nmocks site seems to be down atm, and googling havent been helpfull.
Have anyone experienced a similar problem, or can point me to a mock framework that works in .net 2.0?
Best regards,
Thomas Skovsende
|
|
|
|
|
Hi there,
I'm looking for some good articles on how to upload files using C#, and saving them into a specific directory, this I will probably set in my code.
And lastly, I am looking for articles on how to resize images after it is uploaded. I just need to resize the width and height, that's all, and maybe save the file from .png, or .gif, to .jpg.
I would appreciate it if someone could get back to me on this.
Regards,
ma se
|
|
|
|
|
|
I've written a nice little office add in, but now I need to make it auto updating. I've gone through every piece of sample code and googled like crazy, but I still have the same exact problem I had this morning.
The application updater block pulls the App.config file for the exe that starts a process. For an add in for Excel it's looking for an Excel.exe.Config. Of course it can't find it. You can also pass the updater you "ApplicationID", which is supposed to help in some way I'm sure, but doesn't. Either I'm handing in the wrong applicationID, or in some cases it seems to ignore it.
I've started creating overrides for methods in the Updater Application Block Project, but everytime I think I've got what I need there is another call further along that is calling back to Excel.Exe.Config.
Has anyone created an autoupdating Office Add In, or an auto updating dll. At this point I'm probably at the point where I'll be chucking the UAB and writing this thing myself.
Any help would be greatly appreciated.
Thanks,
Jeremy
|
|
|
|
|
Hi,
I just have a couple of questions:
If I have the following, what is the value of decEuro if the textbox txtEuro is empty? decimal decEuro = Convert.ToDecimal(txtEuro.Text.Trim());
Is decimal the best data type used for a currency value?
/********************************************************/
Check the following function:
public static Object CheckDecimalForDB(decimal decCheckDecimal)
{
if(decCheckDecimal != 0)
return decCheckDecimal;
else
return DBNull.Value;
}
The datatype/type returned when decCheckDecimal contains a value, is decimal, or Object?
/********************************************************/
I need to format data in a data grid, firstly time based on Culture info (South Africa), and secondly, decimal values to contain only 2 decimal places after the comma.
This is how I populate my datagrid with the 2 values:
<asp:Label id="lblDateRequested" Text='<%# DataBinder.Eval(Container.DataItem, "DateRequested", "{0 }") %>' runat="server" />
<asp:Label id="lblAgencyID" Text='<%# DataBinder.Eval(Container.DataItem, "Euro") %>' runat="server" />
"DateRequested" has a datetime datatype in SQL Server, and "Euro" is of type money.
/********************************************************/
I need to post data from one form to another form. I used Server.Transfer but then the new page doesn't display in the url "bar". Basically I just want the data to go from page A to page B. Usually in classic ASP I used Request.Form("txtFName") to get the value of the textbox in page A. I'm not sure if the Response.Redirect method does this, don't think so.
This is all for now, I hope to here from the experts soon.
Regards.
ma se
|
|
|
|
|
Surely if you are unsure of stuff like this, the best thing to do is create a simple console application and try it out?
decimal decEuro = Convert.ToDecimal(txtEuro.Text.Trim());
If the textbox is empty, you'll be trying to convert an empty string to a decimal, and an exception will be thrown so it'll never get as far as assigning decEuro.
public static Object CheckDecimalForDB(decimal decCheckDecimal)
{
if(decCheckDecimal != 0)
return decCheckDecimal;
else
return DBNull.Value;
}
The return type is Object which is the base type for everything. This object will either be a boxed value type of System.Decimal or reference type System.DBNull. You can use the .GetType() method to determine which.
Rob Philpott.
|
|
|
|
|
Thanks.
If the return type is Object, and I do return the decimal value, as for example 10.5, would I still need to convert the value to a decimal where it is being called, or will it assume that it is of type decimal?
Lets say the called is used like this:
paramPound.Value = Globals.CheckDecimalForDB(objProperty.Pound);
Does .value contain a decimal, or must I still use Convert.ToDecimal();??
Do you have any comments on formatting dates and decimal numbers in the datagrid.
|
|
|
|
|
Hi again,
ma se wrote: ...would I still need to convert the value to a decimal where it is being called...
This depends on what you're assigning to. Ultimately the return type is Object even if its a boxed decimal, so unless your assigning to another Object you'd need to cast it. For instance if your paramPound.Value is of type decimal you would have to do this:
paramPound.Value = (decimal)Globals.CheckDecimalForDb(objProperty.Pound)
but this line would throw an invalid cast exception in the instance where you return DBNull.
If paramPound.Value is of type Object, you can leave the cast out, and no exceptions are thrown, but this presumes that paramPound.Value can deal with an object which could either be a boxed decimal or DBNull.
I hope that sort of answers your question...
BTW - I think you are correct to use decimal for currency.
As for the datagrid, I'm afraid I'm unfamiliar with this and have no suggestions.
Rob Philpott.
|
|
|
|
|
Hi again yes,
This how I create my parameter:
SqlParameter paramPound = new SqlParameter("@Pound", SqlDbType.Money, 8);
paramPound.Value = Globals.CheckDecimalForDB(objProperty.Pound);
objCmd.Parameters.Add(paramPound);
I just have 2 questions:
Firstly, because the SQL Server table field is of type money, can I use a decimal? And secondly, with regards to your cast to decimal, it will throw an exception. So the best way to do this is to leave the cast out?
For if you must know, this is my check function:
public static Object CheckDecimalForDB(decimal decCheckDecimal)
{
if(decCheckDecimal != 0)
return decCheckDecimal;
else
return DBNull.Value;
}
How would you do it? Would you just do a test for this when you create your parameters?
Cheers.
|
|
|
|
|
OK. I think you're code is fine as it is.
SqlParameter.Value is of type Object which expects either a DBNull or a value (which is what you give it), and the type SqlDbType.Money is decimal. No casting is necessary.
One point though - this implementation means that a value of 0.00 can't be put into the database. DBNull is used to mean 'not applicable here' not zero. So for instance if you wanted to maintain the balance of a bank account without any funds in it you couldn't. The balance would not be 0.00, the balance would not exist.
Rob Philpott.
|
|
|
|
|
- decimal decEuro = Convert.ToDecimal(txtEuro.Text.Trim()); - would throw an FormatException
- I would say that double would be better for currency
- returned is always object i.e. it is an Object of decimal
- You could look at something like:
System.Globalization.CultureInfo c = new System.Globalization.CultureInfo("en-ZA");//I think?
i don't really know much about this so I can't really help. Or you could format your data in your query before it gets returned to the front end e.g. select convert(varchar(10),DateCaptured,101)... would return me my date already in the format i want
- you could use response.redirect("pageb.aspx?txtFName=" + txtFName.Text + ");
and then at page b you could use Request["txtFName"].ToString();
|
|
|
|
|
Thanks.
I'm still not 100% sure how to format this in the datagrid to the value I want.
|
|
|
|
|
ma se wrote: If I have the following, what is the value of decEuro if the textbox txtEuro is empty? decimal decEuro = Convert.ToDecimal(txtEuro.Text.Trim());
The Visual Studio help file tells you (use MSDN if you don't have Visual Studio) that you will throw an ArgumentException if the value is null, FormatException if "value does not consist of an optional sign followed by a sequence of digits (zero through nine) and an optional decimal point symbol.'
ma se wrote: Is decimal the best data type used for a currency value?
I don't work with currencies, I can't help you there.
ma se wrote: public static Object CheckDecimalForDB(decimal decCheckDecimal)
{
if(decCheckDecimal != 0)
return decCheckDecimal;
else
return DBNull.Value;
}
The datatype/type returned when decCheckDecimal contains a value, is decimal, or Object?
When it contains a value, it will be a decimal. You will need to caste it as such. The proper technique is:
decimal value = (decimal)CheckDecimalFOrDB( d ) as decimal;
if ( value != null ) {
....
}
Again the help file has this documented. Look up 'as operator'.
Can't help you with the Euro Formatting
My suspicion is that you should use the Response.Redirect. The Server.Transfer is performed strictly on the server side, the browser is unaware that it has been directed to a new page. If the user does a refresh, they will be redirected back to the original page.
Response.Redirect causes the browser to request the new page. Values will need to be passed by other means such as a cookie or session state. If session state is used and memory is an issue, be sure to recover the session memory by setting the values to null after you have extracted them.
See the Visual studio help file at ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dv_vbcode/html/vbtskCodeExamplePassingDataFromOneWebPageToAnother.htm
Brian Leach
|
|
|
|
|
Hi guys.I need to build a PlotControl where my graph will be shown but I got no idea how to do it.Maybe anybody an help me with any reference?I would be very grateful
|
|
|
|
|
If you tell me more about your plotboard, do you want to draw it with GUI+, maybe make graphics class, I dont know, send me a mail, I try to help you.
Percy Bloomfield
Santa Cruz - Bolivia
|
|
|
|