Click here to Skip to main content
11,705,098 members (60,920 online)

Comments by dasblinkenlight (Top 56 by date)

dasblinkenlight at 17-Oct-11 5:46am View
   
That's too much code now :) Could you please post only the SQL portion that reads the data for your combo box, and remove everything else?
dasblinkenlight at 12-Oct-11 10:43am View
   
> By the way, I don't understand how division by 4 can be relevant here
Since each three bytes from the original sequence are encoded as four base-64 characters, the length of properly padded result should always be divisible by four. However, padding is mandatory only when multiple base-64 items are concatenated as a single string; in all other cases, it is optional. That is why the divisibility of the length by four has rather limited applicability.
dasblinkenlight at 7-Oct-11 6:13am View
   
The pattern "block all input, wait for a pop-up, and deliver a click to it" reminds me of viruses and adware. You aren't writing any of these nasty things, right?

Just kidding...
dasblinkenlight at 6-Oct-11 10:04am View
   
I assume the shortcut keys work in other applications. For example, F5 pressed in a browser reloads the page, right?
dasblinkenlight at 5-Oct-11 14:44pm View
   
Since RegistryPreset gets string copies of keys in the constructor, and because strings in .NET are immutable, I doubt that your list items actually change with each new insertion. It is a lot more conceivable that the code you use to enumerate the list is incorrect: the results look a lot like the classic LINQ's 'Access to modified closure' mistake. Do you see three identical items when you break on the return statement in the debugger?
P.S. Your code will throw an NPE when it's passed null for rkFrom, because it will try sorting a null result list.
dasblinkenlight at 28-Sep-11 10:57am View
   
if (textBox1.Equals(Keyboard.FocusedElement)) // Do something
dasblinkenlight at 8-Sep-11 17:05pm View
   
The question does not make much sense to me: you refer to a "value of a column" as if it were singular, yet there may be many values in a column. A list view column holds potentially distinct values in each of its rows. Which of these many values would you like your code to use when making a decision to hide the column? Please edit your question to provide more clarity.
dasblinkenlight at 1-Sep-11 8:40am View
   
It's of no consequence that they happen to be consecutive: seven is still followed by a smaller number (five), and five is still preceded by a larger number (seven).
dasblinkenlight at 29-Jul-11 12:29pm View
   
Your solution may get rather slow once the database accumulates 10,000+ quotes, or when you access RDBMS over a slow connection.
This is because ToList() loads all quotes into memory. If you replace the return line with this one
return new Quotes(query.Skip(r.Next(0, count)).Take(1).Single());
the selection process would happen in the database, and the whole process would go at roughly the same speed, no matter how many quotes there are in your database.
dasblinkenlight at 11-Jul-11 12:12pm View
   
Could you post the complete XAML for your textbox, and also for the combobox that works?
dasblinkenlight at 7-Jul-11 14:14pm View
   
Correct, that's how you do insertions. Deletions are generally done in reverse order, although you could also use a cascading delete.
dasblinkenlight at 7-Jul-11 12:18pm View
   
> Hahaha I don't understand that.
You need some theoretical background then - first few chapters of any book on RDBMS would greatly improve your understanding.
> Is there anything I need to change?
Yes, you need to add id columns to both tables, and a foreign key to the table with messages. Adding a foreign key makes tables related. You can copy-paste the declarations from the answer into a query in SQL management studio, and look at the resulting diagram for tables N and M.
dasblinkenlight at 6-Jul-11 8:55am View
   
This question has been edited four times. By the end of the last edit, it has become a different question.
dasblinkenlight at 6-Jul-11 8:22am View
   
// This returns FALSE! HOW?!

mo.StartDate.Value is of type DateTime, which is a struct. It cannot possibly be null.
dasblinkenlight at 4-Jul-11 19:38pm View
   
Not really: _schedule.StartDate is of type Nullable, and that's what the C# code is passing to the constructor of SqlParameter.
dasblinkenlight at 10-Jun-11 9:20am View
   
If it's 100+ columns, your best choice is to become good at reflection: that's what the landman-code guy did :-)
dasblinkenlight at 9-Jun-11 16:55pm View
   
It's worth noting that the article is from 10 years ago, when C# wasn't nearly as powerful as it is today. Even such basic things as generics were missing! As far as the object layout goes, you could write unsafe code to influence your object layout as far back as C# v1.0 (and you didn't need no stinkin' badges to use it back then)
dasblinkenlight at 8-Jun-11 13:15pm View
   
Run Console.WriteLine(typeof(Customer).FullName) and use what's printed in your IS NOT OF(...) statement. I tried a query of the same structure on my EDM (using unqualified Contacts instead of BAEntities.Contacts), and I got the expected results back.
dasblinkenlight at 8-Jun-11 12:12pm View
   
Fixed.
dasblinkenlight at 5-Jun-11 21:44pm View
   
Thanks - I discovered the Blinkenlights quote in a book on embedded systems programming, in the chapter that teaches how to blink an LED programmatically, and I thought that the ending would make for a good user name :)
dasblinkenlight at 5-Jun-11 21:25pm View
   
Deleted
It means that you discovered a good and commonly used pattern all by yourself - congratulations!

I'm sorry I cannot offer help in a language that would be more helpful to you: my other languages are Russian, Ukrainian, and some Italian.
dasblinkenlight at 27-May-11 9:17am View
   
Use Arrays.sort() method to sort the arrays.
dasblinkenlight at 24-May-11 10:03am View
   
If your locks are stored in std::map, you can remove the lock you need to destroy from that map, release the lock on the map, call a pthread_rwlock_rdlock followed by pthread_rwlock_unlock, and finally a pthread_rwlock_wrlock followed by pthread_rwlock_unlock again. Once your call succeeds, you can be sure that (1) all writers that requested the lock prior to its removal from the map have released it (rwlock allows writers to proceed ahead of readers; once you get a read lock, you know there are no further writers), (2) all readers that requested the lock prior to its removal from the map have released it (because you grabbed a write lock), and (3) no new readers or writers are trying to get a hold of it, because you have removed it from the map prior to locking it. This way you can be sure that it's OK to dispose of the lock.
dasblinkenlight at 20-Apr-11 8:46am View
   
From here: http://msdn.microsoft.com/en-us/library/cc646677.aspx, class DataServiceQuery<TElement>, TElement [is the] type of results returned by the query. Your first query (the one that works) returns rows of type CatsMainService.Trader. Your second query returns rows of another type (whatever is the type of the Accounts column), so you should change the second line of your second example to match that type, whatever it is. For example, if s.Accounts is a string, the second line should be var dquery1 = (query1) as DataServiceQuery<string> ;
dasblinkenlight at 8-Apr-11 12:57pm View
   
To me, "native code" and "elegant solution" sound kind of awkward next to each other :)

You could also try GCHandleType.Pinned to avoid letting GC to move your buffer, but I am not sure if it's "kosher" in callback situations: MS recommends unpinning as soon as possible.
dasblinkenlight at 5-Apr-11 15:39pm View
   
Yeah, that's very much the only option there is. The question is, how do you get one if all you've got is a compiled function. The guy at my link suggests decompiling into an expression tree. It would be a lot simpler if the OP could use an expression tree instead, because the code could both examine the tree and produce an executable expression by calling Compile().
dasblinkenlight at 5-Apr-11 15:30pm View
   
From his example it looks like he's not dealing with expression trees, because he gets Func[t] as an argument.
dasblinkenlight at 5-Apr-11 10:08am View
   
I use svn too - convincing MSLCC to ignore what's in .svn directories was not hard (it may have even happened "automagically", I don't remember the details).
dasblinkenlight at 5-Apr-11 6:09am View
   
I think they provide options for you to control file/directory inclusion or exclusion. In general, I remember the setup being somewhat non-trivial (you set up a counting job first, with lots of config options, and then you run a job to obtain the actual counts). The counts are grouped by category (C#, XML, etc.), by project directory, and so on.
dasblinkenlight at 21-Mar-11 6:38am View
   
For all practical purposes, randomly generated GUIDs are safe to use as primary keys in a database.
See the link for the algorithm used to ensure the GUIDs are unique: http://en.wikipedia.org/wiki/Globally_unique_identifier.
dasblinkenlight at 16-Mar-11 7:33am View
   
Tracking updates by modification date is not reliable in the presence of concurrent updates. AD provides a replication protocol accessible over RPC (http://technet.microsoft.com/en-us/library/cc961788.aspx) letting you receive updates, and track them by USN (update sequence number).
dasblinkenlight at 16-Mar-11 6:43am View
   
Yes, that's what we did. We also established a process to sync up the DB from the AD periodically. There is a set of APIs for AD mirroring, letting you code a reliable synchronization relatively easily. Unfortunately, I wasn't working on that part of the system (and the system was coded in Java, too), so I don't remember which API it was.
dasblinkenlight at 15-Mar-11 22:41pm View
   
From my limited and dated experience with the directory services, I remember that searching by non-structural attributes is usually a lot slower than by "structural" ones. Is there a way to restrict your entities by something "stronger" than your otherpager attribute? Unlike RDBMS, you can't tell your directory server to index a particular attribute, so in a sense, you have to "jump through the hoops" to make your queries perform. Faced with a situation when we were allowed to run our queries against the directory server only at specific times to avoid hampering the server performance (our queries were rather demanding), we ended up building a system that copied LDAP entities of interest to an RDBMS repository, and queried that repository instead of LDAP.
dasblinkenlight at 14-Mar-11 12:24pm View
   
Do you have multiple copies of the assemblies in question on your computer? For example, an assembly C could be referenced from assemblies A and B, which come from separate projects, and therefore reference the assembly C separately. In this case CLR could not safely assume that the two copies of C represent the same assembly, unless C has a strong name. Do you see strongly-named assemblies loaded twice as well?
dasblinkenlight at 14-Mar-11 8:36am View
   
Does your application load a lot of assemblies statically (e.g. because of referencing many assemblies at compile-time), or does it load assemblies dynamically? Are the assemblies loaded multiple times built by you or by others? Do the assemblies built by others have strong names?
dasblinkenlight at 7-Mar-11 10:17am View
   
[X] is reachable from [S] means there is a path from [X] to [S]. If your graphs are connected, it's true for all nodes (but I don't know if your graphs are connected). [S]-[A]-[X]-[A]-[T] means a path that goes from [S] to [T] through [X], but it must go through an articulation point [A] two times in order to go through [X] (therefore, [X] is not between [S] and [T]).
Still, it's only a sketch of an algorithm. By adding back some of non-disconnecting articulation points you may get a few nodes (from among the articulation points you added back) that are not between [S] and [T]. Weeding them out may be a bit tricky - I don't have much time to think about it, but I hope implementing a solution would give you some additional insights.
dasblinkenlight at 7-Mar-11 6:26am View
   
I see - the algorithm covers paths [S]-[A]-[X]-[...]-[A]-[T], but I forgot about the case when there's no [X] in between (i.e. [S]-[A]-[T]). To cover it, you can go through the list of articulation points before removing any edges, and create a list of all articulation points reachable from both [S] and [T]. Then add these articulation points back after running the algorithm.
dasblinkenlight at 4-Mar-11 15:03pm View
   
1. Considering that you contemplate using DynamicInvoke anyway, what is wrong with the code you have?
2. Where do the parameters come from? I mean, at some point your code would need to learn the value of X in the call of new object[X]; where does it come from?
dasblinkenlight at 4-Mar-11 10:41am View
   
You can be sure that non-overlapping paths exist without finding all paths. Start by analyzing articulation points in your graph. Find all articulation points (see link above), and then for each articulation point [A] check if the source [S] and the target [T] remain connected when [A] is removed. If removal of [A] does not disconnect [S] from [T], remove [A] and all its edges. The reason this can be done is that [S] and [T] are "on the same side" of [A]; any path from a vertex [X] on the other side of [A] must go through [A] to reach either [S] or [T], meaning that non-overlapping paths do not exist. All vertices connected to [S] and [T] after the algorithm has finished are between [S] and [T]. This algorithm is polynomial - it's complexity is roughly O(V*E).
dasblinkenlight at 4-Mar-11 8:38am View
   
In an undirected graph, "vertices that are between source and target" are such vertices to which there exist non-overlapping paths from the source and from the target. You can check for paths to not overlap by finding <a href="http://www.ibluemojo.com/school/articul_algorithm.html">articulation points</a>. However, the problem you are trying to solve is fundamentally hard. The best way to approach something like that would be to provide user results as you find them. For example, once you get 10 results, show them to the users. If they see an item that satisfies their criteria, you are done. If not, they'd click [Next] and you'd continue searching. The key here would be to search in a smart way, whatever it may mean in your case. Is there a particular statistics they'd wish to maximize? Show the paths that maximize it first. Do they look prefer shorter paths? Show shorter paths ahead of the longer ones. And so on.
dasblinkenlight at 10-Feb-11 10:34am View
   
Actually, the link I posted was more a hint than a solution: I understood from your original post that you did not need a new object. One of the things you should do is to switch from setting fields to calling property setters. Otherwise, your bindings will not know that they need to update.
If instead of GetFields you use GetProperties, you should be able to accomplish what you need (PropertyInfo objects let you access property getters and setters as MethodInfo objects; you can invoke them through reflection).
dasblinkenlight at 9-Feb-11 22:07pm View
   
This looks like a binding issue. Do you see any suspicious messages in VS output window?
dasblinkenlight at 7-Feb-11 17:14pm View
   
Excellent point. Another thing to remember is that Umair's solution would be slow on very large volumes of data, because CONVERT(DATETIME,dtcreated) kills any possibility of indexing.
dasblinkenlight at 2-Feb-11 18:55pm View
   
I just wanted to stay with the code template from the question as much as possible :)
dasblinkenlight at 30-Jan-11 14:42pm View
   
Please edit your question and put "pre" tags around your code. This way the include file names would not be removed as unrecognized tags.
dasblinkenlight at 30-Jan-11 14:18pm View
   
The code in the first part is XAML, an XML-based language used in WPF to mark up the UI. It's not something you'd need to change. Copy it as-is, you don't even need to completely understand it. Download and run the project, see what it does, set a breakpoint or two, check variable values, see what's going on. Ask project author some meaningful questions if you get stuck.
dasblinkenlight at 28-Jan-11 11:54am View
   
It's a homework assignment, isn't it?..
dasblinkenlight at 27-Jan-11 12:27pm View
   
That's an interesting twist. In theory, I don't think it should make a difference. However, in practice I found the implementations of the query mechanisms of these two frameworks to have a number of small but visible differences. We are in the process of migrating a prototype that was built with Linq2Sql to a production system based on EF, and we are discovering such small differences nearly every day.

It would be interesting to see the top of the crash stack of the example that breaks in your case. Is EF anywhere on the stack, or is it just System.Linq.Dynamic?
dasblinkenlight at 26-Jan-11 20:14pm View
   
Are you certain that ctx.Customers has at least one customer with a company name containing capital "A"?..
dasblinkenlight at 25-Jan-11 5:43am View
   
I think this question has a better chance of being answered if you ask it in the DB forum, because it's mostly about fetching data using Entity Framework, and not about displaying it using ASP.NET.
dasblinkenlight at 21-Jan-11 12:49pm View
   
A good program most of the time makes it easy to answer a simple question: "what does this code do?" Trying to figure out the purpose of your piece of code is a puzzle in its own right.

You don't have to take my word for it: remove the words "occurred" and "times" from your code, show the result to your friends, and ask them to tell you what your code does.
dasblinkenlight at 20-Jan-11 5:38am View
   
Nice! BTW, I think the fact that it is happening on DST nights indicates that there's a logical bug in the OS: the modification time of a file is set to the local time, not a UTC time + offset.
dasblinkenlight at 13-Jan-11 8:04am View
   
Could you give more specifics on the "does not work" part? Do you get an exception, or the statement executes without deleting the rows you expected to be deleted? If there's an exception, could you provide the details of it?
dasblinkenlight at 12-Jan-11 16:47pm View
   
Suppose you manage to upcast the pointer to the child class. I still do not see how is it useful, since the static type of *aChildClass remains baseClass. Your script-generated code can make good use of the new type because the pointer inside the 'if' block is statically typed to the child type, but your pseudocode wouldn't be able to do the same, because it does not have thousands of 'if' blocks. A good way to see what I mean would be to try providing an example of what happens after the last line of your pseudocode: you wouldn't be able to call aChildClass->aChildMethod(), unless aChildMethod is in the base class.
dasblinkenlight at 12-Jan-11 12:35pm View
   
From the syntax on the ref manual page it looks like there are no commas between the JOIN clauses. You may also want to consider moving join criteria away from the WHERE clause into the ON clauses of their joins for clarity, like this: delete from apps, contacts, dept using apps join contacts on apps.FileLoc = contacts.FileLoc join dept on apps.FileLoc = dept.FileLoc where apps.FileLoc = '" + id + "'"
dasblinkenlight at 21-Dec-10 11:55am View
   
Could you please verify that none of the item attributes (ProductName, ProductCode, etc.) contain single quotes? A single quote will result in an command that is impossible to parse. In general, forming SQL dynamically is error-prone, because this technique is sensitive to the content of your data. Generally accepted fix involves using SQL parameters.

Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid