|
I meant TreeView control.
Any other ideas?
|
|
|
|
|
use treeView1.SelectedNode.Level to get the level.
use the Parent to get the parent and Node to get the Child nodes.
But I would also recomend a separate list for the search.
|
|
|
|
|
Would a separate list just be quicker for searching, or is there another reason why you recommend it?
|
|
|
|
|
could be quicker but that's not why.
The main reason is that it would be simpler to search.
|
|
|
|
|
Hello every one,
I am trying to store some Unsigned long values in sqlite database using the sqlite.data.dll in c# windows application
i tried to take BigInt as datatype in database but it resulted overflow exception, the result was obvious unsigned long value was too big
So I switched the data type to Numeric in database ... now data is inserting properly
but when i try to retreive the value back using sqlitedatareader the value is truncated
I am totally lost which data type should i use to store ulong value in sqlite database
i dont want to take varchar datatype and if I use binary i'll not be able to query on table for
ulong values
Can any one please help me out what should i useabhinav
|
|
|
|
|
The problem is in SQLite sources:
SQLiteStatement.BindParameter:
case DbType.Int64:
case DbType.UInt64:
this._sql.Bind_Int64(this, index, Convert.ToInt64(obj2, CultureInfo.CurrentCulture));
return;
I dnt know any workaround but I'll try to find...
Here's also uint64-related link: http://sqlite.phxsoftware.com/forums/t/904.aspx[^]
=update=
By the way I've found a workaround:
INSERT query:
using (var cmd = conn.CreateCommand()) {
cmd.CommandText = "insert into tt (text, Value) values (@text, @tt)";
cmd.Parameters.AddWithValue("@text", value.ToString());
cmd.Parameters.AddWithValue("@tt", (long)value).DbType = DbType.UInt64;
cmd.ExecuteNonQuery();
}
SELECT query:
using (var cmd = conn.CreateCommand()) {
cmd.CommandText = "select Value from tt order by Value desc";
var reader = cmd.ExecuteReader();
while (reader.Read()) {
long l = (long) reader[0];
Console.WriteLine(*((ulong*)&l));
}
reader.Close();
cmd.ExecuteScalar();
}
SQLite query for table creation:
CREATE TABLE "tt" (
"ID" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"Text" TEXT NOT NULL,
"Value" UNSIGNED BIG INT NOT NULL
) Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
|
|
|
|
|
Hello Dmitry,
First of all thanks a lot for your quick reply
this work around works great and the value is storing and retreiving properly but now the problem is I cant query the the 'value' field of 'tt' table
select * from tt where value = 18446744073709551614
this does not work
can you please help me.
thanks a lot again for your helpabhinav
|
|
|
|
|
Yeah, you should always pass ulong value as parameter, not as a string inside a query:
using (var cmd = conn.CreateCommand()) {
cmd.CommandText = "select * from tt where value = @val";
cmd.Parameters.AddWithValue("@val", (long)18446744073709551614ul).DbType = DbType.UInt64;
var reader = cmd.ExecuteReader();
...
} Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
|
|
|
|
|
thanks Dmitry that did the trick abhinav
|
|
|
|
|
Good afternoon.
I currently write application to hook copy,cut,paste using ICopyHook whit visual studio 2008.
When I compile my application I have compil error CComModule can't not instantiate abstract class...
I try same code I found in codeproject compile whit vs 2005 and using vs 2008 I have same error.
Can you help me please thank you.
|
|
|
|
|
You need to post your code, in <pre> tags
aurelcly wrote: I have compil error CComModule can't not instantiate abstract class
This indicates that you are trying to create an instance of a class that is marked
abstract , which is impossible. Without the code it is we can't tell why this is happening.Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
|
|
|
|
|
Hi,
I have a question on windows application management. Lets take a look at my problem.
I am writing a windows application in C# 2005. I want that, at a time the application should run once. Unlike windows notepad or other programs the user can open as many windows he wants. But some trial software's don't allow opening more than one instance of same application.
Here, I also want the same facility(limitations) provided by trial software's. So that I can also run my application once at the same time.
|
|
|
|
|
|
Hi All,
In my application one thread waits for AutoResetEvents from various other threads.
I'm using WaitHandle.WaitAny(eventArray) to wait for any one of the events to become signalled then perform a switch on the returned index. My problem is that when 2 or more events are signalled at the same time I only get the array index for one event and the other signalled events are effectively lost. How can I ensure I respond to the other signalled events? It would have been better if subsequent calls to WaitHandle.WaitAny provided the index to these other signalled events on subsequent calls but it doesn't work like that.
Got any suggestions?
Thanks
Paulmodified on Thursday, February 18, 2010 3:55 AM
|
|
|
|
|
paul_b_baker wrote: It would have been better if subsequent calls to WaitHandle.WaitAny provided the index to these other signalled events on subsequent calls but it doesn't work like that.
Are you sure?
An AutoResetEvent remains signalled until it is used to satisfy a wait. WaitHandle.WaitAny is no different in that respect to WaitOne . So if two events are signalled at the same time, one will win the race to satisfy the wait and WaitAny will return it's index. The next WaitAny will succeed immediately and return the index of the other event.
Unless you mean that it is one event that is being signalled twice and one of the signals is being lost. This is a known problem with AutoResetEvent . If this is the case, you will have to use a different synchronization mechanism.
Nick----------------------------------
Be excellent to each other
|
|
|
|
|
Nick thanks but I'm quite sure I've got it right.
If two seperate events become signalled WaitHandle.WaitAny only returns the single lowest index and subsequent calls won't return the other signalled event indexes because, (I'm guessing here) AutoResetEvents are reset when the thread waiting on them runs. So my thread detects one event and runs but clears two or more events!?
Paul
|
|
|
|
|
Nick,
You're right.
In my code I added a check to see if a second event had been signalled when processing the first event. My check involved a call to WaitOne which reset the second event so (obvious after reading your post) I never saw it set in the main WaitAny loop!
I'm eating humble pie right now.
Thanks again.
Paul
|
|
|
|
|
Just some advice for future message posting...
Nick won't see that reply (because you replied to yourself) unless he visits the forum again and looks for this thread.
Further, when you edited your original post to change the title to "SOLVED", you should have put the solution in the original message as well. In a really long thread, very few people will hunt for the "solution" if it's buried deep in the message traffic..45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
No worries, we've all done it! I'm glad you got your bug fixed anyway.
If you can, I would do all threading development on VS2010. The RC is available and includes ( well at least the Ultimate version does ) some very useful new tools. In particular, the concurrency profiler shows you when waits are satisfied and by which thread, which would have been useful in this case.
If you really want to ensure correct code, there is also a CTP of a tool called Chess:
http://research.microsoft.com/en-us/projects/chess/[^]
It systematically explores synchronization interleavings by running tests ( it's a dynamic tool ). It's got a bit of a learning curve and you have to write the right tests, but it's worth it if you are unsure if your program is correct.
Nick----------------------------------
Be excellent to each other
|
|
|
|
|
Hi All,
I want to find how many elements have blank value and the number of that element using LINQ.
I dont want to iterate the array.
Please guy guide me.
Regards,
Sunil G.
|
|
|
|
|
It depends upon what you mean by "blank" but:
String[] foo = { "", "Hello", "", "World", "How", "are", "You", ""};
Console.WriteLine(foo.Count(x=> string.IsNullOrEmpty(x)));
Should give you some idea.
You'll need to change the predicate x=> string.IsNullOrEmpty(x) to suit your needs.Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
|
|
|
|
|
Thanks for your quick reply
It prints : 3.
I also want the index of the element.
In this example it is 0,2 and 7..
How is it possible?
Thanking You,
Sunil G.
|
|
|
|
|
Sunil G wrote: How is it possible?
Iteration. Something has to iterate the array, LINQ is just doing that under the covers.Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
|
|
|
|
|
"Blank" in what way? Array's don't have "blanks" in them, although an array of type T may contain elements with the value default(T) - is that what you want to find?
If so, you might do this: (!!untested!!)
static int CountEmpty<T>(IEnumerable<T> data)
{
return data.Count((T item) => object.Equals(item, default(T)));
}
Someone will have to iterate the array though, even if you don't do it yourself. Without looking at the whole array you can never know that there are no "blanks" left in the part that you skipped.
Except of course if you keep a count of how many elements of the array you changed from blank to non-blank (minus the ones you changed back to "blank") in the first place.
|
|
|
|
|
Good answer. I'd was thinking of null rather than default(T). Regards,
Rob Philpott.
|
|
|
|