|
Super Lloyd wrote: I want no insignificant 0, but as many relevant number as possible!
A zero isn't insignificant, it means that the value at that position is zero. There's a huge difference between 1 and 1.0 in terms of knowledge - the latter one is more precise. Numbers are relevant up to the specified precision.
I are Troll
|
|
|
|
|
The documentation states that. "The scaling factor also preserves any trailing zeroes in a Decimal number. Trailing zeroes do not affect the value of a Decimal number in arithmetic or comparison operations. However, trailing zeroes can be revealed by the ToString method if an appropriate format string is applied".
I guess this behaviour is what makes dealing with decimals more accurate by avoiding some of the issues regarding doubles.
"You get that on the big jobs."
|
|
|
|
|
Hey, I didn't read the documentation carefully enough! :P
Anyway, one reason decimal are more human and accountant friendly is that number are stored as ... decimal! I.e. the same representation we used to read / write!
I.e. every 4 bits is stored a number between [0 8[
unlike float and double which are a sum of a power of 2 values...
they are also much slower!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
hi guys...i get some informations from a site Xml file and convert that file to DataTable and then save it in my form's load..it works well but the problem it works very very slow..when i clicked the button to open my form it takes one min almost to open it..how can i make it faster to work..here is the codes i wrote...
public XmlNodeList XmlListesi()
{
XmlDocument doc = new XmlDocument();
doc.Load("http://cekilis.millipiyango.gov.tr/haftalik_loto_bilgileri.xml");
XmlElement root = doc.DocumentElement;
XmlNodeList elemlist = root.GetElementsByTagName("haftalik_loto_bilgileri");
return elemlist;
}
public DataTable ConvertXmlNodeListToDataTable(XmlNodeList xnl)
{
DataTable tablo = new DataTable();
int TempColumn = 0;
foreach (XmlNode item in xnl.Item(0).ChildNodes)
{
TempColumn++;
DataColumn dc = new DataColumn(item.Name, System.Type.GetType("System.String"));
if (tablo.Columns.Contains(item.Name))
tablo.Columns.Add(dc.ColumnName = dc.ColumnName + TempColumn.ToString());
else
tablo.Columns.Add(dc);
}
int ColumnsCount = tablo.Columns.Count;
for (int i = 0; i < xnl.Count; i++)
{
DataRow dr = tablo.NewRow();
for (int j = 0; j < ColumnsCount; j++)
{
try
{
dr[j] = xnl.Item(i).ChildNodes[j].InnerText;
}
catch (Exception)
{ }
}
tablo.Rows.Add(dr);
}
return tablo;
}
public void InsertSayisal(DataTable dt)
{
cmd = dal.InsertSayisal();
cmd.Parameters.AddWithValue("@cek_no", System.Data.SqlDbType.Int);
cmd.Parameters.AddWithValue("@cek_tarih", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@num1", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@num2", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@num3", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@num4", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@num5", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@num6", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@altibln", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@besbln", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@dortbln", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@ucbln", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@alti_ikr", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@bes_ikr", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@dort_ikr", System.Data.SqlDbType.NVarChar);
cmd.Parameters.AddWithValue("@uc_ikr", System.Data.SqlDbType.NVarChar);
for (int i = 0; i < dt.Rows.Count; i++)
{
cmd.Parameters["@cek_no"].Value = dt.Rows[i][0].ToString();
cmd.Parameters["@cek_tarih"].Value = dt.Rows[i][1].ToString();
cmd.Parameters["@num1"].Value = dt.Rows[i][4].ToString();
cmd.Parameters["@num2"].Value = dt.Rows[i][5].ToString();
cmd.Parameters["@num3"].Value = dt.Rows[i][6].ToString();
cmd.Parameters["@num4"].Value = dt.Rows[i][7].ToString();
cmd.Parameters["@num5"].Value = dt.Rows[i][8].ToString();
cmd.Parameters["@num6"].Value = dt.Rows[i][9].ToString();
cmd.Parameters["@altibln"].Value = dt.Rows[i][10].ToString();
cmd.Parameters["@besbln"].Value = dt.Rows[i][11].ToString();
cmd.Parameters["@dortbln"].Value = dt.Rows[i][12].ToString();
cmd.Parameters["@ucbln"].Value = dt.Rows[i][13].ToString();
cmd.Parameters["@alti_ikr"].Value = dt.Rows[i][14].ToString();
cmd.Parameters["@bes_ikr"].Value = dt.Rows[i][15].ToString();
cmd.Parameters["@dort_ikr"].Value = dt.Rows[i][16].ToString();
cmd.Parameters["@uc_ikr"].Value = dt.Rows[i][17].ToString();
try
{
cmd.ExecuteNonQuery();
}
catch (SqlException)
{
}
}
}
vemedya.com
|
|
|
|
|
Hi,
I don't have the answer, I do have a lot of questions and some suggestions:
1.
how many rows and columns are in your DataTable?
2.
why are you swallowing exceptions? it is dumb to do so, as it hides potential or real problems you are having. Log them to a log file, and look at it. Don't use MessageBoxes, they are just annoying. Use at most one, at the end of an operation, to say something went wrong and more details are in the log file.
3.
why are you storing almost everything as a string? it wastes time and disk space, and it probably hampers functionality too.
4.
why are you repeating the same operations all the time? e.g. I see lots of dt.Rows[i] you would better fetch the row once and keep it in a local variable.
5.
I can't tell how long dal.InsertSayisal() should take, you should look into that method too.
6.
you could use a StopWatch to get timing information, and log that to your log file, together with some extra information; that way you could see how your code behaves, i.e. where exactly time gets wasted.
7.
if, I don't know, your DataTable's only purpose is to get the XML data to the database, then maybe you would be better off doing it in a single loop, one row at a time, avoiding the need to keep everything in memory at once. (Depends on #1).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Use XmlTextReader instead of XmlDocument. XmlDocument will sit there reading and indexing the whole document before you can start working with it. XmlTextReader will stream the data so you can work while it is reading. Just note XmlTextReader is harder to work with.
"You get that on the big jobs."
|
|
|
|
|
Ditch the DataTable . Ditch all those ToString s.
|
|
|
|
|
thanks for your suggestions guys..i will change something in my codes by your suggesstions
vemedya.com
|
|
|
|
|
hi everybody!!!
there´s an API for personalized mmc???
I want to program a management console for 10 computers conected in a simple network and My wish is use a personalized Management console for many uses!!
does anybody know something like that?
thx
Greg
|
|
|
|
|
GREG_DORIANcod wrote: does anybody know something like that?
There's a CodeProject article[^] on the subject, it might help
I are Troll
|
|
|
|
|
You can start from there[^] and this[^] article also might help you.
|
|
|
|
|
Hi all, I am trying to accessing a image file from my project. I am getting error saying the path is not valid or Null value.
In my Projec I have folder name Image and it has some bmp files and I am trying replace the bmp file one by another depends on the condition
I have placed. Two concerns.
1. access the bitmap file
2. replace image from the pictureBox to another.
thanks,
|
|
|
|
|
The simple way:
Image i = Image.FromFile(path); However this will lock the file until the Bitmap object is Disposed.
A longer way is to use a stream:
Image i;
using (Stream s = System.IO.File.Open(path ,System.IO.FileMode.Open ))
{
i = Image.FromStream(s);
}
Then just display what you need to:
myPictureBox.Image = i;
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Hi OriginalGriff,thanks for your reply. I have problem accessing my file. So, what I did is put those .bmp files in the bin debug folder and
PictureBox.Image = New Bitmap("myImage")
Now it is working.
thanks.
|
|
|
|
|
I think I understand the problem.
If you don't specify an absolute file path, the .Net will try and find the image relative to your current program, hence moving the bitmaps solved the problem.
If you don't want the images in the same folder as your program, the simplest solution is to specify their absolute path (e.g. c:\Folder\myImage.bmp)
If you do want the images to be kept in your program folder, and they are part of your VS project, make sure their Copy To Output Directory property (right click the file, select properties) is set to Copy Always or Copy If Newer.
|
|
|
|
|
Take note of what Tony says, but also be aware that the new Bitmap(path) constructor does exactly the same thing as the Image.FromFile(path) method: It locks the file until the Bitmap is disposed. MSDN[^]
What that means is that is you do:
PictureBox.Image = New Bitmap("myImage")
PictureBox.Image = New Bitmap("myOtherImage")
PictureBox.Image = New Bitmap("myImage") You will get an exception because the file "myImage" is in use for the third bitmap.
That doesn't mean you can change images in a button click event: the file remains locked until the Bitmap is Disposed. I.e. when the Garbage collector finally gets called in, and decides it is no longer needed. That could be now, could be next week. Use the Stream method instead: it does not have that problem.
[edit]Luc kindly pointed out that it is a read lock, so only write, rename, and delete operations will be affected. So if you are just displaying the image and not changing the file, it won't be a problem.[/edit]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
modified on Monday, February 28, 2011 3:27 PM
|
|
|
|
|
OriginalGriff wrote: You will get an exception because the file "myImage" is in use for the third bitmap.
Now there is a bit I disagree with. The Bitmap class locks files as you say, however they are writer locks, not reader locks. So you can't alter, delete, rename the file while such bitmaps are not disposed (*), but you can open them for reading as often as you like.
(*) or is it indisposed?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I'm glad you disagree, because it made me check! That'll teach me to trust MS documentation...
Since it said "The file remains locked until the Bitmap is disposed" I stupidly assumed it meant "Locked" not "Read locked".
Oh, well - I learnt something new, and any day when you do that is not wasted.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
I did test your example before posting, as it didn't fit with earlier experience, and it seemed to behave much like EXE files do: you can launch them many times, however as long as a process is executing an EXE, the file can't be written/renamed/deleted. So yes it is locked, but not completely locked. I don't know what the official terminology is, what comes to mind is FileShare.Read as a parameter to File.Open
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Makes sense when you think about it - I modified my response to correct it.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I Have a Large Data about 20000 Recored How Can I Load It Into Combobox Without Using For Loop Or Froeach Loop??????
EASY COME EASY GO
|
|
|
|
|
That large data you have in SQL Table or where else are stored?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
I know this isn't the answer you want, but, well...
sanforjackass wrote: I Have a Large Data about 20000 Recored How Can I Load It Into Combobox
Don't.
Seriously, no one wants to scroll through 20,000 records. Give them a search interface or something.
|
|
|
|
|
the problem is i want to load only names in it then when he type some words combobox will complete it and load the rest of the record so i need to load all names in combobox.items
(i used before foreach loop but it is too slaw)
EASY COME EASY GO
|
|
|
|
|