|
Dave,
I wonder what happened to you on this one: the general slowness of filling a standard WinForms TextBox control, or NotePad, with a large amount of Text is not relevant here at all.
How, I wonder, did such an inane response get three up-votes ?
The reason I am doing this stuff with showing a lot of text is related to software development; it has nothing to do with production mode, and some final software a user would interact with. I am examining the results of building a very large collection of a complex object, and that means I want to inspect the result in detail at run-time (much easier than setting a break-point in Visual Studio, and drilling down through little windows you have to scroll-in endlessly to reach item 899,233 out of 1 million).
The relevant issue is what I perceived as an inaccurate result using Stopwatch.
Alan's answer below points out the simple (and stupid) mistake I made in syntax.
Using Win 8/64, Visual Studio 2012 v.3, FrameWork 4.5, compiling to "AnyCPU," in Debug mode: using relatively old hardware (6420 CPU at 2.13mhz., 4gb. ram):
fyi: I can fill a TextBox with fifty-megabytes of text in around 33 seconds.
fyi: Using a RichTextBox I can fill it with fifty megabytes of text in under 3 seconds
fyi: converting a StringBuilder containing 50 mb. to a string: itself takes about 2 seconds.
fyi: NotePad ? I use UltraEdit, which can open a 50 mb. text file in under 3 seconds.
But, knowing someone with your skills can have an off-day, as I did; knowing you are imperfect, as I am: well, I feel less lonely
your friend, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
My machine is a bit slower than yours. I can't do 50MB in 30 second.
But, you're correct. I lost my head had on this one.
|
|
|
|
|
A man who knows he lost his head, and gracefully admits it, is a man who has, not only a head, but a heart
appreciatively, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
|
Ooh, that's difficult to spot. The mistake is subtle, easy to make and I'm sure I've done the same thing.
Stopwatch.Elapsed is a TimeSpan and TimeSpan.Milliseconds is just the millisecond component. If the measured value is less than 1 second then the result will be correct but either Stopwatch.Elapsed.TotalMilliseconds or Stopwatch.ElapsedMilliseconds would be what you really wanted.
Alan.
|
|
|
|
|
Alan, you nailed it ! And, how gently you broke the news, thanks
I was relieved to search all my code for the last several years, and find not one instance where I had made the same mistake made here: but, not relieved enough to get over the chagrin of making such a stupid mistake now.
I owe you an elephant-ride in the jungle in northern-Thailand.
yours, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
|
|
|
|
|
To suppress the warning CA2100 i am trying to create a parameterized query. By the following code.
string sheet_name=listBox_Select_a_sheet.SelectedItem.ToString();
OleDbCommand cmd = MyConnection.CreateCommand();
cmd.CommandText = "SELECT count(*) FROM [?]";
cmd.Parameters.AddWithValue("?", sheet_name);
cmd.ExecuteNonQuery();
The value of the ? is not replaced.
I have also tried the following
OleDbCommand cmd = MyConnection.CreateCommand();
OleDbParameter para = new OleDbParameter("?", sheet_name);
cmd.Parameters.Add(para);
cmd.CommandText = "SELECT count(*) FROM [?]";
and
string strSql = "SELECT count(*) FROM [@Name]";
cmd.Parameters.AddWithValue("@Name", sheet_name);
My aim is to replace the ? with the parameter.
And one more doubt is can we use parameterized query to replace a table name?
|
|
|
|
|
Parameters do not work for table identifiers. They only work for columns or other identifiers that use data types, such as stored procedure parameters.
|
|
|
|
|
Thank you for your kind reply. That was very helpful. One more thing need to be cleared. How can we suppress the warning CA2100 : Microsoft.Security for the following code?
string sheet_name=listBox_Select_a_sheet.SelectedItem.ToString();
string strSql = "SELECT count(*) FROM sheet_name";
using (OleDbCommand cmd = new OleDbCommand(strSql, MyConnection))
{
cmd.ExecuteNonQuery();
}
|
|
|
|
|
Turn off Code Analysis when you compile. It's not a compiler warning but a code analysis warning. This is to remind you that you should not use user input directly when building your SQL statement as a string.
|
|
|
|
|
Thank you so much for your kind support. I have learned new things on parameterized OleDB Query. I hope to help help other in future.
|
|
|
|
|
gautamn1990 wrote: To suppress the warning CA2100
Never heard of it, never seen it. I do something like:
string strSql = System.String.Format ( "SELECT count(*) FROM [{0}]" ,sheet_name) ;
for table names there's really no substitute.
|
|
|
|
|
Thank you for your reply. I tried your concept. the name is getting replaced but during code analysis CA2100: Microsoft.Security: warning is still appearing. Sting sheet_name is value in obtained from users input by the following code.
string sheet_name=listBox_Select_a_sheet.SelectedItem.ToString();
string strSql = "SELECT count(*) FROM sheet_name";
using (OleDbCommand cmd = new OleDbCommand(strSql, MyConnection))
{
cmd.ExecuteNonQuery();
}
How to supress the CA2100 Warning:MicroSoft.Security ?
|
|
|
|
|
gautamn1990 wrote: during code analysis
Is that an option you turn on? Like FxCop or similar? I've never seen that warning.
|
|
|
|
|
i have problem in dataGridView1
Problem is When i select a record in dataGridView1 Combo Box "Medicine Category" then it show Name of Category in dataGridView1 Combo Box "Medicine Name" First,
When i Select 2nd Row Record"Medicine Category" then it fill Medicine Name problem
e.g:
Ist row Select Syrup then show Medicine Name(Cough)
2nd row Select Tablets then show Medicine Name (Panadole)
but it change Records Ist Rows
the code is :
string query = "select * from item_detail where m_type = '" + GridView_Purchase.Rows[e.RowIndex].Cells[0].Value.ToString() + "'";
cbName.DataSource = dbSelect.selectRecords(query).Tables[0];
cbName.DisplayMember = "m_name";
|
|
|
|
|
I hav a datagridviewview in windows application whose column names are set from the fron end i setted their propertyname also cause i wanna to bind it with database, just like as
Name Address
Admin Delhi
so m wanna tht as i will click on address cell of any row there is one combobox will show who is binded with database
and as i will click on another row, the previous row will be show normally as a textboxcolumn and currentcell with show as a combobox column who will also binded with database
|
|
|
|
|
I've read your post a couple of times, but I can't find a question or find at which point you got stuck. Can you explain what behaviour you were expecting, and the actual results? With a part of the code to demonstrate the problem?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello Sir,
Look i have a datagridview who is binded with database and shows those values
Name Address
admin Delhi
adam India
as i'm going to click on delhi my datagridview will show a combobox on click of it and shows a list of cities from database
and after selecting any value from combobox i'm moving toward next row so as i'm going to next row m wanna tht combox will convert into textboxcolumn again thts the problem happening with me.
Hope so tht now u can understand my problem...
|
|
|
|
|
Arun kumar Gautam wrote: Hope so tht now u can understand my problem... Sounds more like a specification than a problem.
You can add a DataGridViewComboBoxColumn[^] to the DataGridView s "Columns" collection. Also note;With the DataGridViewComboBoxColumn, you can display a column of cells that contain drop-down list boxes. This is useful for data entry in fields that can only contain particular values, such as the Category column of the Products table in the Northwind sample database. [...] Combo box columns are not generated automatically when data-binding a DataGridView control. To use combo box columns, you must create them manually and add them to the collection returned by the Columns property. Samples are here[^], walktroughs and howto's over here[^].
Hope that helps to get you started
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hie,code team members
currently i make a project on school management team,i use .net framework 4.0 and linq for coding.
i want to put single sign on using active directory concept in web-application.
so my question is that how i implement in it my project.
give me tips for that
Thanks in advance....
Regards !
ketan
|
|
|
|
|
ketan italiya wrote: give me tips for that I've got something better than a tip; documentation[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanks Eddy....it will helpful for me...
|
|
|
|
|
You're welcome
|
|
|
|
|
|
I'm developing a C# windows program that, among other things opens up a configuration file and reads in the data and responds appropriately. I currently have the path to this configuration file hardcoded. It's located in the installation directory "C:\Program Files\... but I was wondering if there's a shortcut of some kind to get the location of the program that's running, and use that to grab the configuration file, so I don't have to hardcode it. Thanks.
|
|
|
|