|
I cant seem to format my strAverageDensity which originally is in this example strAverageDensity = 30.000000123
using: string.Format("{0:0.00}", strAverageDensity);
need it to equal 30.00 in this case but 2 decimal places
instead its still strAverageDensity = 30.000000123
so this is the code:
EditSubCategory E = new EditSubCategory();
SubCategory C = GlobalContextManager.Instance.Cache.GetSubCategory((int)R.Cells[0].Value);
Category CC = GlobalContextManager.Instance.Cache.GetCategory(C.CategoryId);
string strAverageDensity = Convert.ToString(GlobalContextManager.Instance.Conversions.ConvertMetricWeightToDefault(C.AverageDensity));
E.ParentCategory = CC;
E.Category = C.Name;
E.IsActivated = C.IsEnabled;
E.OriginalCategory = C.Name;
strAverageDensity = string.Format("{0:0.00}", strAverageDensity);
E.AverageDensity = strAverageDensity;
|
|
|
|
|
strAverageDensity should be of type float or double and not string to take advantage of numeric format strings.
|
|
|
|
|
Try:
strAverageDensity = string.Format("{0:0.00}", C.AverageDensity); which I assume is a float / double. Strings do not use numeric formats!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
you failed to show an essential line of source code. Now compare yours to this:
float f=30.01234f;
log(string.Format("{0:0.00}", f));
string s="30.01234";
log(string.Format("{0:0.00}", s));
|
|
|
|
|
As has already been pointed out, this format string works with numeric types. Why don't you try?
double dAverageDensity = Double.Parse(strAverageDensity);
strAverageDensity = String.Format("{0:0.00}", dAverageDensity);
|
|
|
|
|
hi dear friend.
i am a regular programmer,but i think this line of your program can be change
string strAverageDensity = Convert.ToString(GlobalContextManager.Instance.Conversions.ConvertMetricWeightToDefault(C.AverageDensity));
instead of Convert.ToString(...) use of System.Convert.ToString(...).
i hope success for you.
M.Shooster
|
|
|
|
|
You could try Substring.... 
|
|
|
|
|
substring is chopping strings, not rounding numbers.
|
|
|
|
|
He seems to want to round a string.
|
|
|
|
|
Yes it sure looks that way, although he never said it explicitly.
So he should parse and either round or format, as ignrod suggested.
|
|
|
|
|
Luc Pattyn wrote: he should parse and either round or format
I disagree. 
|
|
|
|
|
I am writing a program to send email. When I send from my own email accounts everything works! When I send from my company email or any other emails from the company I get the error: “The remote certificate is invalid according to the validation procedure”
The code looks like this:
<br />
mailObj = new SmtpClient("smtp. MyCompany.com", 25);<br />
from = new MailAddress("xxxxxx@MyCompany.com", "Chris H");<br />
AuthInfo = new NetworkCredential(from.Address, "xxxxxxxxxxx");<br />
to = new MailAddress("xxxxxxxx@hotmail.com", "Chris H");<br />
MailMessage mail = new MailMessage(from, to);<br />
mail.Subject = "Testing";<br />
mail.Body = "Hello Everybody";<br />
<br />
mailObj.UseDefaultCredentials = false;<br />
mailObj.EnableSsl = true;<br />
mailObj.Credentials = AuthInfo;<br />
mailObj.Send(mail);<br />
I have noticed that in our Outlook account settings - More Settings - Outgoing server we need to check the My outgoing server (SMTP) requires authentication and "Use same settings as my incoming mail server"
This would make me think my program should be able to get the authentication info need from the incoming mail server but how??
Any words of wisdom would be appreciated.
|
|
|
|
|
|
To confirm what Matt has said above, the company I work for has several domains but we use just the one certificate for IMAP SSL so the certificate fails on anything but the domain the cert is for. I use the RemoteCertificateValidationCallback delegate to examine any policy errors and disregard RemoteCertificateNameMismatch .
Check what yours is failing on and disregard if appropriate.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
I don’t see how to implement RemoteCertificateValidationCallback into my code. Our email is hosted by an outside company that is not very helpful so I don’t have access to their resources. All I have access to is my little program to help our salesmen respond to leads. This program would be run on the salesman’s PC while out of the office not on the ‘email server’. This may be the perfect response but I need a bit more guidance to see how to implement it.
|
|
|
|
|
If i recall correctly (I don't have the code here at home) all you need to do is add this before you enable SSL
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);
and set up the method
private bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
bool result = true;
return result;
}
You'll need these usings if not already present
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hello again
im trying to merge two datatables as such
Table 1
row1 0 x x
row2 0 x x
row3 x 0 0
Table 2
row1 x 0 0
row2 x 0 0
row3 0 x x
merge them to
final table
row1 0 0 0
row2 0 0 0
row3 0 0 0
is there a way to do it (using merge?).i wont be able to use foreach or for loop (i think)as some of the rows are not in order ?
|
|
|
|
|
I like SQL for this using the UNION statement is that is an option.
|
|
|
|
|
|
SELECT
customerName,
createDate
FROM
customer
WHERE
createDate BETWEEN '2009-10-01' AND '2009-10-31'
UNION
SELECT
employeeName,
hireDate
FROM
employee
WHERE
hireDate BETWEEN '2009-10-01' AND '2009-10-31'
|
|
|
|
|
That's not what the OP is looking for. Union will merge the rows of the queries used, but will not merge any columns. The OP has 2 datatables that have different columns filled and he wants them merged into a single one.
SG
Aham Brahmasmi!
|
|
|
|
|
datatable1 = datatable2.Copy();
I know nothing , I know nothing ...
|
|
|
|
|
norjali wrote: i wont be able to use foreach or for loop (i think)as some of the rows are not in order ?
If the rows aren't in order, or if it doesn't have a Key, it's not reasonable expecting any inbuilt merge to work right? And no, there's currently no merge that can do this.
If you know the data better, try to find a candidate for a PK, that'll help you with your looping. Or look at the source of the data, a DB table perhaps? And see if that table has a Pk and try using that.
There's also a Join available for datatables, but you'd need a relation for that to work too.
SG
Aham Brahmasmi!
|
|
|
|
|
This is too customised. What do you mean by Row 0?
You will have to write a custom SSIS package or code.
|
|
|
|
|
Hi.
I have a program that runs as a scheduled task. The program runs on XP as SYSTEM.
The idea is that the program will run in the background, while USER is active.
I need the program to logoff USER when specific conditions occur.
I tried using
[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int uFlags, int dwReason);
but that appears to not log USER off.
I think maybe it's logging SYSTEM off, as it is running as SYSTEM.
How can i logogg USER?
Thanks,
SummerBulb.
|
|
|
|