|
Ok, I think I'm getting somewhere..
After the creation of your treeNode object, we dive in it again in a loop to fetch a node and add it to its parent in the tree.. However, I'm still missing something, please take a look..
foreach (DataRow row in dt.Rows)
{
int parentId = int.Parse(row["PARENT"].ToString());
treeView1.Nodes[baseLine.FindNode(parentId).Id].Nodes.Add(row["ID"].ToString(), row["NAME"].ToString());
}
|
|
|
|
|
Hey there Nav,
Just came up with another way to do it and thought you should know...
private DataTable GenDT(string strSelect)
{
if (con.State != ConnectionState.Open)
con.Open();
DataTable _dt = new DataTable();
try
{
new OracleDataAdapter(strSelect, con).Fill(_dt);
}
catch (Exception) { }
return _dt;
}
private void LoadChilds(string _Parent, TreeNode _Node)
{
DataTable dt = GenDT("SELECT ID,PARENT,NAME FROM TT WHERE PARENT ="+_Parent+" ORDER BY ID");
for (int x = 0; x < dt.Rows.Count;x++ )
{
_Node.Nodes.Add(dt.Rows[x]["ID"].ToString(), dt.Rows[x]["NAME"].ToString());
LoadChilds(dt.Rows[x]["ID"].ToString(), _Node.Nodes[x]);
}
}
private void pop_GTree()
{
DataTable dt;
dt = GenDT("SELECT ID,PARENT,NAME FROM TT WHERE PARENT = 0 ORDER BY ID");
foreach (DataRow row in dt.Rows)
treeView1.Nodes.Add(row["ID"].ToString(), row["NAME"].ToString());
foreach(TreeNode tn in treeView1.Nodes)
LoadChilds(tn.Name, tn);
}
Haven't put it through a heavy test but it looks fine.. Can you please take a look with your sharp logic and let me know if there's any potential run-time problem in the LoadChilds method?? Thank you Nav, and what about the co-article thing?? Are you in?? I suppose we write about this together and I manage the control part and loading the tree using this way, and you handle the linq part.. what do you say?? CPians love co-articles
|
|
|
|
|
This looks OK other than it is requesting each time to database. If you can afford that, this will work. Other alternative is to load the whole data into a DataTable first, and LoadChilds method look into this DataTable instead of querying database. DataTable has a Select() method which can be useful here.
Muammar© wrote: and what about the co-article thing??
I appreciate your offer. But right now I am in a hurry and getting my things packed as I am traveling to US for an official trip. So I guess my schedule in the coming days will be busy and probably not even gets time to check mail.
Also, this is a basic concept and CPians will have pretty good idea about this. Not sure that article will be clicked. You can try to post it as a blog. I found this[^] article to be quite related to the tree view concept. It has got a similar table structure.
|
|
|
|
|
Hey Nav,
N a v a n e e t h wrote: DataTable has a Select() method
It's a stand alone database and yet I'd better adopt that, Thank you for your valuable comment.
N a v a n e e t h wrote: I am traveling to US
Do you work for the united nations?? Cuz I do.. Anyways, have a safe flight, enjoy being there and good luck on your mission!
About the article, yes it has the same data structure but you cant find one similar article in windows forms but anyways, I'll let you know when my part is ready and email it to you and if you're interested/have the time by then, you can simply add your part "mainly the linq part"..
Nice to meet you Nav.. I really appreciate all the time you spent on this thread and I have to say, I learn a lot from you.. Thank you!
Truly Yours,
Muammar.
|
|
|
|
|
Hello,
VS 2008 SP1
I am using the DownloadDataAysnc. But the ProgressChanged event doesn't show progress until after the data has been downloaded.
Even when I try and download a data which is contained in a big file. The programs remains responsive so I know it is doing something. However, it is when the progress has completed that the progressChanged event fires.
I known this as the progressChanged and the DownloadDataCompleted fire immediately after each other. However, they should be a pause as the file is quite big.
This is the code snippet I am currently using. And the output below. What is strange the e.progresspercentage is 100%. And seems to get called twice.
Many thanks for any advise,
Results:
Progress changed Version userstate: [ Version1 ]
progressBar1.Value [ 100 ]
Progress changed Version userstate: [ Version1 ]
progressBar1.Value [ 100 ]
Completed data: [ 1.0.11 ]
private void UpdateAvailable()
{
WebClient wbCheckUpdates = new WebClient();
wbCheckUpdates.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wbCheckUpdates_DownloadProgressChanged);
wbCheckUpdates.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wbCheckUpdates_DownloadDataCompleted);
DownloadFiles df = new DownloadFiles();
string webServerURL = df.webServerPath;
wbCheckUpdates.DownloadDataAsync(new Uri(Path.Combine(webServerURL, "version.txt")), "Version1");
}
void wbCheckUpdates_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
Console.WriteLine("Progress version changed userstate: [ " + e.UserState + " ]");
progressBar1.Value = e.ProgressPercentage;
Console.WriteLine("progressBar1.Value [ " + this.progressBar1.Value + " ]");
}
void wbCheckUpdates_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
byte[] result = e.Result;
Console.WriteLine("Completed data: [ " + System.Text.ASCIIEncoding.Default.GetString(result) + " ]");
}
|
|
|
|
|
steve_rm wrote: But the ProgressChanged event doesn't show progress until after the data has been downloaded.
Yes, this because of UI thread is different from you background thread.
You have to use Background Worker for resolve is Issue. Where you can so Progressbar continuing along with dowloading.
Here is an sample example of Background worker,
Using the BackgroundWorker Component in .NET 2 applications
Hope this will help you
|
|
|
|
|
Hello,
Thanks for the reply.
According to this msdn.
http://msdn.microsoft.com/en-us/library/system.net.webclient.downloadprogresschanged.aspx
The DownloadDataAysnc does show progress.
Not sure why mine doesn't.
Many thanks for any other suggestions,
|
|
|
|
|
Are you by any chance downloading from a passive FTP-server? Just found this in the documentation;
If the server does not send the size of the downloaded file (such as in the case of a passive FTP connection), ProgressPercentage may always be zero.
What happens if you put a breakpoint in the DownloadProgressChangedEventHandler ? Does the break get hit during download?
I are Troll
|
|
|
|
|
Hello,
I am downloading from a http web server using IIS;
Thanks,
|
|
|
|
|
Can you verify (using a new project, just for testing) whether this adapted code works as expected?
static void UpdateAvailable()
{
WebClient wbCheckUpdates = new WebClient();
wbCheckUpdates.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wbCheckUpdates_DownloadProgressChanged);
wbCheckUpdates.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wbCheckUpdates_DownloadDataCompleted);
string webServerURL =
@"http://download.wikimedia.org/simplewiktionary/20090801/simplewiktionary-20090801-pages-articles.xml.bz2";
wbCheckUpdates.DownloadDataAsync(new Uri(webServerURL));
}
static void wbCheckUpdates_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
Console.WriteLine("Download progres: " + e.ProgressPercentage);
}
static void wbCheckUpdates_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
Console.WriteLine("Completed");
}
static void Main(string[] args)
{
UpdateAvailable();
Console.ReadKey();
}
"The human mind ordinarily operates at only ten 10% of its capacity, the rest is overhead for the operating system"
|
|
|
|
|
Hi,
what Abhijit Jana told you is correct.
Steve1_rm wrote: The DownloadDataAysnc does show progress.
No. What the MSDN page says is "(This event) occurs when an asynchronous download operation successfully transfers some or all of the data." So it tells you some progress has been made, it does however run on some thread (most probably a ThreadPool thread) different from the main thread, and hence it is not allowed to touch any Control.
You may want to read some of my articles:
- http://www.perceler.com/articles1.php?art=asyncpool1[^]
- http://www.perceler.com/articles1.php?art=crossthreads1[^]
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,
I've got a few comments on the code although it does look essentially correct and I can't see anything that is obviously broken.
1) In the completion handler there is no check for success and without that it is not possible to draw any conclusions about other parts of the operation.
2) In the example given the results string is very short, only 6 characters, and so it is quite possible that the first progress notification is 100%. Log the e.BytesReceived and e.TotalBytesToReceive values to get a bit more info here.
3) Bear in mind that UpdateAvailable will return before the download is complete as DownloadDataAsync is non blocking. This leaves the WebClient object eligible for garbage collection and that could cause problems.
Example code for checking successful completion:
private void DownloadDataCallback (Object sender, DownloadDataCompletedEventArgs e)
{
if (e.Error == null && !e.Cancelled)
{
byte[] data = e.Result;
}
else
{
}
}
I've read the other responses and it has been suggested that you should not update the progress bar directly due to cross thread issues. I disagree as WebClient operates in the same way as BackgroundWorker with event notifications marshaled to the UI thread. This means your code is safe without using Invoke on the controls.
Alan.
|
|
|
|
|
Hello,
I have an application made in visual C# which is largely dependant on communicating with an online MS Access database (hosted on jabry.com). It will have several users who are going to update the information on the database, so having it locally is not an option. I have tested it locally, and it works without any problems. I have no idea how to write the connection string for when it is ONLINE though. I've tried a lot of stuff... but nothing is working.
Any help would be greatly appreciated!
|
|
|
|
|
Define "online"?
If you're talking about user who have to get to the Access database over the Internet, then you've picked the wrong database engine entirely.
|
|
|
|
|
I use sql server but i think it works quite the same
"It will have several users who are going to update the information on the database"
remember to manage threads in your applications if you didn´t do that yet
"I have no idea how to write the connection string"
download microsoft absolute beginners lesson videos (it´s free), there you will find out how to connect to a databade from a asp site
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Does the server allow remote connections? I seriously doubt it - databases that are provided by an online webhost are usually not available for connection from your local machine.
Same goes for MySQL en SQL Server. They're usually not open to "the internet", and as such, you cannot use such a database as a shared repository. You can use them in a webapplication, once it is installed there (local!)
I are Troll
|
|
|
|
|
Greetings to everyone ... I have a question Can < I write programs in C # to Micro Controllers, as in the C language >
< Are there any functions to control the language or are of limited use >
|
|
|
|
|
Not that I'm aware of. Depending on the µC you're using, your possible chices will probably be C, some variation of BASIC, or assembly.
Personally, I do all my stuff in assembly with µCs, I've never felt the need to use a higher level language with them.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thank you very much .( DaveyM69) .. But something did not take advantage
1-Can < I write programs in C # to Micro Controllers, as in the C language ???>
2-< Are there any functions to control the language or are of limited use ??? >
|
|
|
|
|
Nasir13 wrote: Can < I write programs in C # to Micro Controllers, as in the C language ???>
Allow me to repeat the same stuff for DaveryM69. NO - you cannot write anything for microcontrollers in C#. C# requires that the .NET Framework be installed on a machine running the code. Since your microcontroller isn't running Windows, this is impossible.
Nasir13 wrote: 2-< Are there any functions to control the language or are of limited use ??? >
The question makes no sense. I have no idea what you're trying to say.
|
|
|
|
|
No, none exist (that I know of).
You could possibly write a wrapper around the microcontroller's opcodes, and write code to generate Hex files from that - effectively a C# to uCxxx compiler, but that is going to be a pretty big task.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Totally agree with Davey here. I generally use c/c++ for even embedded processors, let alone micro-controllers.
|
|
|
|
|
Greetings and thank you .. Answer like a fire escape
I am a new user to the language of C #, I used VB to control
May be most programmers in C # to develop the site or building applications
But the question of experience in Imktlk Pic
Can I write programs and transfer the file to Hex in C # ????
|
|
|
|
|
Greetings and thank you .. Answer like a fire escape
I am a new user to the language of C #, I used VB to control
May be most programmers in C # to develop the site or building applications
But the question of experience in Pic
Can I write programs and transfer the file to Hex in C # ????
|
|
|
|
|
There is no compiler for C# to pic or any other microcontroller. It is very unlikely that there would ever be one, nor would I want to use it if there were. C# is heavily heap based; garbage collection is a necessity and would increase in frequency with the reduced memory associated with microcontrollers. If you want a garbage collected memory system in a real-time environment, then you need to think quite carefully about the implications: What happens when you need a variable under interrupt and the garbage collection is required?
I would normally use Assembler, C or C++ but with caution: I never use malloc/free or new/delete in an embedded system because I would expect the unit to run 24 hours a day, 365 days a year. Since malloc/free and new/delete can fragment the heap and cause failure I allocate memory either statically or once only and then re-use. This is not feasible in C#.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|