|
(Note that this post might seem familiar since i already posted it on the MSDN forums which was the wrong place)
Hello,
First of all, sorry for the title and the location of this post. i'm still sure i did something wrong there .
Now for the situation: I have a datasource ( +- 20 mb ) containing more then 100 000 elements where each element contains 4 properties which i need to download from the web.
Then i need to display this datasource in a winforms app. I only need to download this datasource once so it seems logical i save it at the disk for persistence. The datasource is already sorted by name which is good since its a requirement to search for certain elements within the datasource. My goals are to achief the above situation with the least system resources consumption possible ( not that its strictly required but... heck, you know what i mean )
Current progress: I download the datasource chunk by chunk so i can progress one element at a time. When a element got retrieved, i immidiatly create an object out of it and serializes it to the disk to a single file (shared by each element ofcourse) using the XmlSerializer. So far, all goes great, i made a few optimalisations where i dont serialize each element one by one but rather store them in a buffer of X size and serializes the buffer when full, which seems to improve performance.
When all elements are downloaded and stored, i use a listview in detailed view with multiple colums and virtual mode on. As far as i know, this should be one of the most efficient ways of displaying the data. Now comes the real bottleneck. I need to read in the data dynamicly, that is if i need element X to Y and dont want to read in any elements outside that range. XmlSerialization is no go since it always reads in all data, So does XmlDocument (and its rather slow). I cant use XLinq since im targeting .NET 2.0 so i was thinking about XPathDocument. XPathDocument comes with a few drawbacks for what i know. Most importantly, it seems that its loading the entire document in memory which i try to avoid. Next, when for example, scrolling up in the listview, i cant seem to find a way within the navigator to navigate upwards, even better. I cant seem to access a specific element at an index without having to create a new navigator, but these problems might just also be my lack of knowledge of the XPathDocument.
Question: Can anyone help me determine the best way to handle this specific situation?
Note that im not restricted to the above situation so please correct me on ANY part.
Thanks in advance,
Koen
|
|
|
|
|
Firstly I would store the table in a database, SQL Express by preference and Access under duress. All your problems go away when you use a DB as it is designed to serve up smaller chunks that 20mb.
I would then set up a filtering UI so the users can see the minimum number of usable records at any time, I find about 100 to be a good number. It depends on your data structure but with 4 fields there should be some grouping and after that try alphabetical.
I find a datagridview to be dramatically faster loading that a listview, even if the resources are higher.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thank you for the answer,
I doupt i can use a database since the application is clientside and all data should be handeled clientside. Because this application will be published on the web and i want the app to require the least ammount of prerequisites possible. Therefore, i cant expect the user to have some kind of db software installed (e.g. access or sqlserver) << I just assumed access is only avail when having the packet installed (from the office disk or wherever its located these days). Also, i like to build a mono version in the future so i need to watch out for microsoft specific solutions. (sorry for me not putting all this information in the original post)
Ill do some comparison with the listview vs the datagrid, lets see what happens...
Note that since you named access, i was thinking about using ado.net with a xml provider. Havent used this before though so i dont know if its a advantage. Within my knowledge, ADO.NET still needs to build his indexes for the datastore each time its opened right, they might have optimized memory consumption within this..., ill look into it.
Did i say something ridiculesly stupid up here? if not, does anyone have any other input?
Thanks again,
Koen
|
|
|
|
|
Hi there,
Help required....
I am using SourceGrid in .net winform ... I want to know how to set different fonts in different cells.
Regards,
Balu
|
|
|
|
|
balukg wrote: I am using SourceGrid in .net winform
What is SourceGrid?
Never heard of it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
This is what I am trying to do:
Public Class MainForm
Private Split As SplitContainer = Nothing
Public Shadows Property IsMdiContainer() As Boolean
Get
Return (Split IsNot Nothing)
End Get
Set(ByVal value As Boolean)
If value Then
If Split Is Nothing Then
Split = New SplitContainer
Split.Dock = DockStyle.Fill
Split.Panel1.BackColor = Color.Aqua
Split.Panel2.BackColor = Color.Wheat
Me.Controls.Add(Split)
End If
Else
If Split IsNot Nothing Then
Me.Controls.Remove(Split)
Split = Nothing
End If
End If
Me.Invalidate()
End Set
End Property
End Class With this code, I should be adding and removing a SplitContainer to my form instead of an MdiClient control. When I set IsMdiContainer in the Properties panel, however, my code is never run and the framework adds the MdiClient . If I can get this running, I believe I can create a custom Mdi set-up that allows for the parent form to have a sizable sidebar.
What am I doing wrong?
|
|
|
|
|
TechBearSeattle wrote: When I set IsMdiContainer in the Properties panel, however, my code is never run and the framework adds the MdiClient.
That is because the designer knows nothing about your class or your implimentation of IsMdiContainer. It calls the original code as Shaddowing is not the same as Overriding. It is important to know the difference.
I've got a blog post explaining the difference with the examples in C#. All you need to remember is that
* virtual = Overridable
* override = Overrides
* new = Shaddows
Method shaddowing Vs. Overloading[^] (in VB parlons)
|
|
|
|
|
That is not quite the answer I wanted; I was using Shadows because IsMdiContainer is not overridable. But it did point me to a workaround.
Basically, I have to create a base form that has the property IsMyMdiContainer , then set the mdi form to inherit from that. This is the only way I can get the property to show up in the Properties window for some reason; apparently the IDE (in Visual Basic, at least) looks to the parent class and not the class itself. Then I use the new property rather than the old one. Not as drop-in-and-go as I would have liked, but it works.
Thanks for the answer.
Oh, and great examples in your blog entry
|
|
|
|
|
Hello evryone,
When i m build my projcet. that is successfully build but when i m debuging they give me this exception . i dont know why. please help me . i did not solved my problem.
what is the meaning of this Excetion. please help me .
Code......
using System;
using System.Xml.XPath;
using System.Data.SqlClient;
using System.Data;
using System.Xml;
using System.Xml.Xsl;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
namespace DatabaseLayer
{
public class DatabaseLayer
{
private MySqlConnection _connection = null;
private string _connectionString = string.Empty;
public string ConnectionString
{
set { _connectionString = value; }
get { return _connectionString; }
}
public DatabaseLayer()
{
//
// TODO: Add constructor logic here
//
}
public bool OpenConnection()
{
ValidateConnectionString();
_connection = new MySqlConnection();
_connection.ConnectionString = _connectionString;
string exx;
try
{
_connection.Open();
}
catch (Exception ex)
{
exx = ex.Message;
_connection = null;
return false;
}
return true;
}
public bool CloseConnection()
{
bool result = true;
try
{
if (_connection.State == ConnectionState.Open)
{
_connection.Close();
}
}
catch
{
result = false;
}
finally
{
_connection = null;
}
return result;
}
public void ValidateConnectionString()
{
if (0 == _connectionString.Length)
{
throw new Exception("No connection string has been supplied");
}
}
public int ExecuteNonQuery(string storedProcedure, MySqlParameter[] parameterArray, MySqlParameter outputParam)
{
int result;
MySqlCommand comm = null;
string msg;
result = 0;
try
{
//ValidateConnectionString();
//conn = new SqlConnection();
//conn.ConnectionString = _connectionString;
comm = _connection.CreateCommand();
//conn.Open();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
outputParam.Direction = ParameterDirection.Output;
comm.Parameters.Add(parameterArray);
result = comm.ExecuteNonQuery();
result = int.Parse(outputParam.Value.ToString());
}
catch (SqlException ex)
{
msg = ex.Message;
}
finally
{
comm = null;
}
// result = SqlHelper.ExecuteNonQuery(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
public int ExecuteNonQuery(string storedProcedure, MySqlParameter[] parameterArray)
{
int result;
MySqlCommand comm = null;
string msg;
result = 0;
try
{
//ValidateConnectionString();
//conn = new SqlConnection();
//conn.ConnectionString = _connectionString;
comm = _connection.CreateCommand();
//conn.Open();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
result = comm.ExecuteNonQuery();
}
Eror on this line// catch (Exception ex)
{
and there also erro// msg = ex.Message;
}
finally
{
comm = null;
}
// result = SqlHelper.ExecuteNonQuery(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
public object ExecuteScalar(string storedProcedure, MySqlParameter[] parameterArray)
{
object result;
MySqlCommand comm = null;
string msg;
try
{
comm = _connection.CreateCommand();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
result = comm.ExecuteScalar();
}
// catch (Exception ex)
// {
// msg = ex.Message;
// }
finally
{
comm = null;
}
//ValidateConnectionString();
//result = SqlHelper.ExecuteScalar(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
public DataSet ExecuteDataSet(string storedProcedure, MySqlParameter[] parameterArray)
{
DataSet result = new DataSet();
string msg;
MySqlDataAdapter da = null;
da = new MySqlDataAdapter();
MySqlCommand comm = null;
try
{
comm = _connection.CreateCommand();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
da.SelectCommand = comm;
da.Fill(result, "data");
}
// catch (Exception ex)
// {
// msg = ex.Message;
// }
finally
{
da = null;
comm = null;
}
return result;
}
public MySqlDataReader ExecuteReader(string storedProcedure, MySqlParameter[] parameterArray)
{
MySqlDataReader result = null;
MySqlCommand comm = null;
comm = _connection.CreateCommand();
string msg;
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
try
{
result = comm.ExecuteReader();
}
catch (Exception ex)
{
msg = ex.Message;
}
finally
{
comm = null;
}
// ValidateConnectionString();
// result = SqlHelper.ExecuteReader(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
public DataTable ExecuteDataTable(string storedProcedure, MySqlParameter[] parameterArray)
{
//SqlParameter[] parameter = new SqlParameter[2];
//parameter[0] = new SqlParameter("@userIDN", SqlDbType.Int);
//parameter[1] = new SqlParameter("@activeFlag", SqlDbType.Bit);
//parameter[0].Value = applicationUserIDN;
//parameter[1].Value = activeFlag;
DataTable result = new DataTable();
string msg;
MySqlDataAdapter dataAdapter = null;
dataAdapter = new MySqlDataAdapter();
MySqlCommand comm = null;
//OpenConnection();
comm = _connection.CreateCommand();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
//comm.Parameters.Add(parameter[0]);
//comm.Parameters.Add(parameter[1]);
foreach (MySqlParameter param in parameterArray)
{
comm.Parameters.Add(param);
}
try
{
dataAdapter.SelectCommand = comm;
dataAdapter.Fill(result);
}
// catch (Exception ex)
// {
// msg = ex.Message;
// }
finally
{
CloseConnection();
dataAdapter = null;
comm = null;
}
return result;
}
public MySqlDataReader ExecuteReader(string storedProcedure)
{
MySqlDataReader result;
MySqlCommand comm = null;
string msg;
comm = _connection.CreateCommand();
comm.CommandText = storedProcedure;
comm.CommandType = CommandType.StoredProcedure;
// foreach (SqlParameter param in parameterArray)
// {
// comm.Parameters.Add(param);
// }
try
{
result = comm.ExecuteReader();
}
// catch (Exception ex)
// {
// msg = ex.Message;
//}
finally
{
comm = null;
}
// ValidateConnectionString();
// result = SqlHelper.ExecuteReader(_connectionString, CommandType.StoredProcedure, storedProcedure, parameterArray);
return result;
}
}
}
Thanks in Advance
|
|
|
|
|
Someone may be able to answer your question, but I cannot.
Not unless I can see at least a little of your code. Please modify your post to include the relevent part of your code, the part where the error occurs. Point out the line causing the exception.
This will enable those of us without super powers to help you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
That is better, but I won't read through all that, at least in the horrible unformatted state.
Put the code inside <pre> tags like this:
<pre>
code here...
</pre>
and format it properly, you know - proper indenting and so on. (If you do the <pre> tags first, and then paste your code in again, it will retain the proper formatting.
Also make it really clear which line is giving the exception. You may have done this already, but I'm not going to search through that lot for it.
It makes my eyes hurt!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I second that. Except the part about your eyes, that I don't know.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi,
I'm developing a Windows Forms application that will be translated to all kinds of languages, including Simplified Chinese. On Windows Vista it works just fine with the Segoe UI font, but on XP all Chinese chars become boxes due to that it falls back to Tahoma.
Does anyone have a suggestion on an alternative font that I can use? Preferably it should be installed by default on Windows XP, it should not be too different from Tahoma or Sagoe UI and finally it should be possible to use for most languages out there, ie have a full Unicode set of characters.
Best regards
Christian
|
|
|
|
|
I don't understand your question. Are you asking us what default fonts are installed on what OS's?
|
|
|
|
|
Sort of... I'm not located in China myself, so I'm not aware of what fonts support the Chinese character set. I have Googled this issue but I wasn't able to find a suitable answer, because I do not want to use different fonts for Chinese, Japanese etc. which is the usually suggested approach. Segoe UI would be the perfect choice, but it's not always available on XP. So question is if there is a similar font on XP?
This problem should be very common, since my program is not the first to be translated into Chinese. Rather than going through hundreds of fonts, which is what I'm planning to do today I popped the question here.
|
|
|
|
|
Sorry, I lost track of this thread, my fault.
Christian Wikander wrote: Segoe UI would be the perfect choice, but it's not always available on XP. So question is if there is a similar font on XP?
Have you considered making the Segoe font part of your installation?
|
|
|
|
|
Yes, I have considered it.
As I understand it I may not distribute it without a separate license from the author. While not impossible to overcome, it adds some extra hassle with my boss.
Secondly my application is distributed through ClickOnce. It seems like an extra hurdle to distribute and use it given that the application has no rights at all in the client system.
At this point I more or less gave up to be able to move on. I wrote some code that change the font to one of the Sim* fonts if needed.
Nevertheless, thanks for the reply.
|
|
|
|
|
i wish to generate a html or chm help file from a application windows forms ,please give me the source code c# for this application.
thank you
|
|
|
|
|
System.IO.TextWriter tw = new System.IO.StreamWriter("C:\\example.html");
tw.WriteLine("<HTML><BODY>");
tw.WriteLine("<P>Hello World :)</P>");
tw.WriteLine("</BODY></HTML>");
tw.Close(); You just wanted the source, so here it is.
Enjoy
I are troll
|
|
|
|
|
I am working on a winforms project with an MDI Parent and some MDI Children. The Child datasets Fill methods use a parameter set by a combobox on the MDI Parent. I can iterate through the active MDI children, but cannot figure out how to refresh the dataset in the children when the parameter changes, which would then update the data being displayed. I tried invoking .refresh method on the child forms, but it does not refresh the dataset. Any ideas would help.
Thanks Paul
|
|
|
|
|
|
Hello Friends..
I have created setup in vb.net windows appliation.
I want to run another .exe file from command prompt at the time of setup
which has been already created during setup.
.exe file is created in my installation folder.
But problem is
How can i find my installation path during installation.?
Thankx in advance...
|
|
|
|
|
That depends on what you are using to do the installation. Some installers let you start a proces by script, others have it completely integrated (where you only set properties) and some don't provide this functionality at all
I are troll
|
|
|
|
|
Thankx Eddy Vluggen.
I am using wizard to install s/w step by step.
One step will ask user to where to install the s/w.
I want to know this path.
Hope See u again..
|
|
|
|
|
Dear All.
i want to raice Esc key(keybord) Event, without pressing the Esc button.
Regards
Rajeesh MP
|
|
|
|
|