|
Also, don't use XMLChildNodeList.Item(i).GetType().ToString() != "System.Xml.XmlComment" ; look into the is operator.
|
|
|
|
|
I commented the lines where I build the tree in the function, so now the function only travels in the file. Also when the function ends (completely) I pop up a Message Box, and it took exactly a second for the application to pop up the message, so it's probably the way I build the tree.
|
|
|
|
|
that is the way to go: split it up in smaller pieces, so you can see which one takes too much time.
alternatively, add logging code, where each message shows time in milliseconds, as with DateTime.Now.ToString("HH:mm:ss.fff")
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi all, still haven't find the downer...
but I encourage you all to try this tutorial, which is actually the base of my source code: How to populate a TreeView control with XML data
This is a Microsoft tutorial, really short and simple - just copy and paste. Try loading a large XML file (440K and above), if anyone has insights I would love to hear!
|
|
|
|
|
Hi,
Can any one suggest me how to convert HTML file to Excel and Pdf .
In C# Code only
I have html file i want 2 generate that file to Excel and PDF
|
|
|
|
|
|
Im writing a simple control to use in my app. It consists of a button with two labels on it, each displaying different data.
Heres my problem:
When I use the control in my app, I have to click twice on the labels to trigger the click event of the control while clicking on a part of the button with no label on it works correctly. I assume the way to handle this is to tie the labels click events to the controls click event. I have managed to setup properties correctly to alter label text and color and what not but how do I go about linking the click events"
Thanks,
Jon
|
|
|
|
|
I'm guessing then that the purpose of the two labels are to display some kind of relevant data that is refreshed upon clicking the button?
If that is the case, it might be considered a better UI strategy to have the two labels above the button rather than on it, and the button labeled "Refresh".
But if you are intent on keeping other controls on top of your button, then yes, you could simply have the label click handler and the button click handler each call the same code method.
|
|
|
|
|
Actually no, the data on the labels doesnt change once it is set. The button is for music, the top label is the song title and the bottom is the album name. When the user clicks anywhere on the button(including on the labels), the song should loaded into the queue to be played.
Problem is when the user clicks on a part of the button with a label, they have to click twice in order to trigger the load.
|
|
|
|
|
Actually no, the data on the labels doesn't change once it is set. The button is for music, the top label is the song title and the bottom is the album name. When the user clicks anywhere on the button(including on the labels), the song should loaded into the queue to be played.
Problem is when the user clicks on a part of the button with a label, they have to click twice in order to trigger the load.
|
|
|
|
|
Hi,
Just wondering...
I downloaded the MySQLConnection library for VS. I'm using the code below to try and connect to a MySQL database on my webpage.
It's not working though
Anyone tried doing this before?
<br />
<br />
string server = "Server=http://www.somepage.org.nz;Database=somedatabase;Uid=myusername;Pwd=mypassword";<br />
MySqlConnection con = null;<br />
try<br />
{<br />
con = new MySqlConnection(server);<br />
con.Open();<br />
this.label1.Text = con.State.ToString();<br />
}<br />
catch (Exception ex)<br />
{<br />
this.label1.Text = ex.Message;<br />
}<br />
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
|
Hi,
1) First you need to add reference MySql.Data to your application.
2) Then //create a new mysqlconnection
MySqlConnection mycon = new MySqlConnection("datasource=localhost;username=root;password=pwd;database=project");
//create a mysql DataAdapter
MySqlDataAdapter myadp = new MySqlDataAdapter("select * from FAB", mycon);
//create a dataset
DataSet myds = new DataSet();
//now fill and bind the DataGrid
myadp.Fill(myds, "empinfo");
dataGridView1.DataSource = myds.Tables["empinfo"].DefaultView;
I have used with windows application. Try this.
Regards,
Subbu
|
|
|
|
|
MarkBrock wrote: string server = "Server=http://www.somepage.org.nz;
That's not going to work. You cannot access a database over the HTTP protocol.
Your corrected string should look more like:
Server=someSqlServer.somepage.org.nz;
But, that's not likely to work either. Either the MySQL server has to be exposed directly to the Internet (a REALLY STUPID thing to do), or that site has to expose some other method of interaction with the database, such as a Web Service.
|
|
|
|
|
Dave Kreskowiak wrote: ...exposed directly to the Internet (a REALLY STUPID thing to do)...
5.
|
|
|
|
|
Thought that might be the case, cheers Dave.
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
i am reading a CSV file and getting error that file is in use. i am trying to read CSV file by ado.net and fill the dataset.
my code is as follows :-
---------------------------
DataTable dt = null;
bool flag;
DataSet objDS = new DataSet();
OdbcConnection mobjCon = null;
try
{
string mstrConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + Path.GetDirectoryName(strFilePath) + ";Extensions=asc,csv,tab,txt;Persist Security Info=False";
string strQuery;
mobjCon = new OdbcConnection(mstrConnectionString.Trim());
mobjCon.Open();
strQuery = "select * from [" + Path.GetFileName(strFilePath) + "]";
OdbcDataAdapter mobjAdapter = new OdbcDataAdapter(strQuery, mobjCon);
mobjAdapter.Fill(objDS, "phone");
CreateTableInDatabase(tableName);
using (SqlBulkCopy bc = new SqlBulkCopy(Business.ProgramConnections.OrcsConnectionString))
{
bc.DestinationTableName = tableName;
bc.WriteToServer(objDS.Tables["phone"]);
bc.Close();
flag = true;
}
if (flag)
{
mobjCon.Dispose();
FetchData(tableName);
}
}
catch (Exception objEx)
{
throw objEx;
}
finally
{
if (mobjCon.State == ConnectionState.Open)
{
mobjCon.Close();
}
}
in this above way i am trying to fill dataset with data from CSV file.
i am getting error because file is opened by another application.
i want that if the file is opened by another application inspite of i want to read this CSV file and populate my dataset. so please anybody rectify my code to read the locked CSV file and populate the dataset.
if possible give me a sample code by which i can read any locked CSV file, i mean in use CSV file and populate my dataset.please help me this is urgent.
Thanks in advance
tbhattacharjee
|
|
|
|
|
Tridip Bhattacharjee wrote: want that if the file is opened by another application inspite of i want to read this CSV file and populate my dataset
If the other application has the file opened with DenyShareWrite, or any other variant that deny's you access to the file while it has it open, you're screwed. You simply have no choice but to wait for the other application to close the file before you can read it.
|
|
|
|
|
but i know that the file is not opened with DenyShareWrite mode. i could open that file with excel and could read that is why i think it can be read with readonly mode. so please guide me with sample code.
thanks
tbhattacharjee
|
|
|
|
|
If that's the case, then you've got a shot at this.
The problem is, AFAICT, there's no way to tell the Text driver to open the file with SharedRead permissions. You'd have to use the standard file operations to open the file yourself, then read it and parse each line. An example of opening the file can be found here[^].
You'll find a few CSV libraries laying around CodeProject. Here's[^] a short list.
|
|
|
|
|
Hi again, more questions.
In my project I have this service layer I am using, to simplify it could be like this:
ServiceClient myService = new ServiceClient();
SomeDataType[] result = myService.GetSomeData(...arguments...);
myService.Close();
It's 3rd party layer and lacks proper documentation so I played around with this. With some arguments the result is null . I already have my application use these results in grids and with CurrencyManager and BindingContext . The design is assuming that these results from service methods should never be null (but what if they are).
So I decided to do "helper" class which will contain all those service calls and throw exception if data is not valid instead of checking if the data is valid outside.
ServiceClient myService = new ServiceClient();
SomeDataType[] result;
try
{
result = myService.GetSomeData();
if (result == null)
{
throw new ArgumentNullException("result", "Service method GetSomeData() returned null.");
}
}
finally
{
myService.Close();
}
return result;
Because the service raises no exception in the testing case I had it return null, it just returned null, though it has to be a case of an exception because it never shouldnt. So would this be the "proper" way to make sure I get the exception when I think the underlying layer (service) should have raised it?
|
|
|
|
|
Why there is a static constructor in the following Singleton example? :
public sealed class Singleton
{
static readonly Singleton instance=new Singleton();
static Singleton()
{
}
Singleton()
{
}
public static Singleton Instance
{
get
{
return instance;
}
}
}
|
|
|
|
|
Well, because its a homework question and you are meant to know
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Dont spam the forum with answers that are helpless and stupid
|
|
|
|
|
you want only clueless and stupid questions then?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|