Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. Illusion, I'm not being rude, but have you read all the replies that are provided in this thread? It's not clear to me that you have. For example, I said you'd likely have to replace all "Long" with "Integer" yet your sample shows you're still trying "Long." Also, have you tried PD's example or mine, where you just change the border style and other properties of a form (no API call needed)? Did that work or not work? If it didn't, what was wrong about it or what behavior did you see that didn't work the way you expected? -nerseus
  2. If this is text on a label, I'd suggest creating your own label. There's a sample "vertical label" control here: http://www.codeproject.com/vb/net/vertical_label.asp If you need more generic drawing, I'd read through the posts again. First, make sure you do ALL your custom drawing in some kind of Paint event. And, if you're going to create your own Graphics object, make sure you Dispose of it when you're done. If you're using a Paint event that provides e.Graphics, then do NOT dispose of it. :) -ner
  3. If you just want fullscreen, I do it with setting the border style to none and window state to maximized - you can also set TopMost to true. Those three properties should make the form go fullscreen, covering even the taskbar and system tray. If you want "true" full screen, with mouse capture and all including preventing Alt-Tab from switching, you're likely thinking of DirectX or similar libraries that allow more "total control." That's a lot more work. If you want the API to work, just change the call to accept an IntPtr and make sure the other params are all "Integer" instead of "Long" - assuming you're using a 32 bit version of Windows. If you've got WinXp for 64 bit then you're on your own :) For example: Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As IntPtr, ... -ner
  4. hamid, I think you've got two options: 1. Include everything you can in your WHERE clause to limit the update to one row. amir's suggestion should work for you for the sample data your provided: [highlight=sql]UPDATE Table1 SET Value=6 WHERE Name='n1' AND Value=1.[/highlight] 2. Add a primary key to the table - something that will uniquely identify every row. Unless you don't have access to change the table, I'm not sure why you wouldn't want to do this. Having a primary key on every table is standard practice - most database engines will even warn you when creating tables without one. -ner
  5. Whoops - I completely missed the parens on his code. Good catch! :) -ner
  6. The original code is looping over each character (or position, really) in the string. A foreach isn't *guaranteed* to loop in order so I'm not sure that's what you'd want. I think the equivalent foreach wouldn't be very nice, but here's something to try if you want: 1. Convert the string into an array of char. 2. Foreach char in the array of char For "foreach" to work, you've got to have something you can enumerate over - generally some type of array or list. A string doesn't have that natively - you'll have to convert to an array of some kind. If you have an array of strings, or a string with a delimiter, then you should be able to "foreach string in stringarray". Your sample didn't seem to show that though... Let us know more of what's going on and we may be able to help more. -ner
  7. Two options, depending on your preference: 1. Setup a relationship between your two tables - delete from the parent (Group) and it will cascade the delete down for you. 2. Manually delete from child tables first (User), then from the parent (Group). Where I work, we use SQL server and set up our foreign keys to enforce parent/child relationships but we do not turn on cascading (for updates, deletes, etc.). We use option 2 as it makes us aware of what we're deleting when we want to physically delete. For #1, go to Tools->Relationships to open the designer. Create the link there to turn on the cascading deletes. For #2, just execute the "DELETE FROM Users ..." first. Unsolicited Advice: In either case, I would highly recommend deleting from Groups by GID instead of GroupName. You said you had AutoNumber turned on so you're guaranteed to get only one group. If you go in by name, there's a chance you may hit more than one. Besides, the ID seems more natural to me when referencing exact rows. -ner
  8. Were happy to announce that Syntax Highlighting is back! The following tags are supported natively: vb vbnet cs csharp Usage is: [ CODE=visual_basic]VB code here[/code] The syntax highlighting system has support for many other languages. Usage is: [ code=<language>]Code goes here[ /code] Where <language> is a supported type (see below). So you cant use [ xml] ... [ /xml] but you can highlight xml through the syntax above. We've also turned on "Similar Threads". If you scroll to the bottom of a post, past the Reply box, you'll see a grid of similar threads that may be of use. Thanks, The Team at .Net Help Community Languages supported: apacheconf applescript aspnet bash c clike coffeescript cpp csharp css diff git html http ini java javascript json jsx less makefile markdown nginx objectivec perl php python ruby sass scss sql svg swift wiki xml yaml visual_basic vbnet
  9. What about Scotland? For some reason, I'm fascinated by Scotland - can't wait to go there one day. -ner
  10. Someone borrowed my copy of Effective C#. I believe the author had a very good description of structs and exactly why they're immutable, and why any value types you create SHOULD be designed to be immutable. With 50 tips in the book, I've obviously forgotten the reason why :) If I can find my copy, I'll try and write up the summary of what he presented. -ner
  11. Is there, by chance, a circular reference between the two projects? Do you have them setup as project references or file references? If you have file references and a circular reference, as well as having the assemblyInfo files having a hard-coded version number, you might get this error. It's just a guess, but that's mine. You can email me the project at nerseus at google mail dotcom (you know the one, gmail.com). If you do, please include some basic instructions for setting it up. You can often reduce the size of project by removing the bin and obj folders, if that helps. -ner
  12. @Mike: By "new style" I just meant using Trace.Assert vs a standard "if (some condition) throw new Exception()". I wish I had more time to spend on getting some initial unit testing framework in place. If so, I think I'd end up preferring unit tests over Trace.Assert as I should be able to validate my data much easier that way and it would keep all those validation/assumptions in one place rather than within a method. -ner
  13. I generally try to enforce arguments with Trace.Assert, if I want to catch it at debug time. To check for a null string, I'd use the following right at the top (before I use "Try"): Trace.Assert(stringsArray == null, "stringsArray == null"); Some prefer Debug.Assert, but I'd rather get this error in QA than nothing. As for inner exceptions - I've never used them myself. I've looked at them while debugging and some unhandled exception is thrown. Within my catch blocks I generally log an error to our standard logging and then use "throw;" to re-throw the error. In other places, I might throw a new exception (such as new ArgumentException) rather than Trace.Assert - but that wouldn't be from within a Catch block. I prefer the new style of Trace.Assert, just because it's easier to remember for me. In general, I don't use try/catch that much - only around code that might possibly have an unexpected error such as every call to the DB or to a webservice. If I'm processing data in a DataSet or doing something with UI code, I wouldn't expect an exception and wouldn't want a try/catch just because I'm unsure. That's our general guideline where I work - don't use try/catch unless there's a call that may throw an exception that you couldn't have prevented with an "if" test. -ner
  14. A DataSet is the only object provided by .NET that provides native undo, that I'm aware of anyway. If you use it properly (and I know I've not always done it right), you mark rows for Edit and later use AcceptChanges or CancelChanges (that name might not be right). At any time, you can see the original values through various methods - for example, the DataTable Select() method has an argument for DataViewRowState (again, may not be exactly right) to get at OriginalValues, CurrentValues, etc. Rockford Lhotka's book(s) "Expert C# Business Objects" (he has about 4 versions of this book/idea), describes a custom set of business objects that natively support multiple levels of undo. I own the C# version of the book and have read through a lot of it, but in the end it seemed easier to code our own object model using other pieces we already had built (and understood better), so I can't say that I've really seen how he handles it. If you're looking for references, that book may help. You can also google for CSLA to get more info. -ner
  15. Since the code is likely a bit larger than your sample, I'd think that moving the code inside of the loop into a separate function. That separate function is responsible for the file creation/writing/closing. In that function you'd have a try/catch/finally. Something like this: Private Sub ProcessButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProcessButton.Click For Counter As Integer = 1 To Some Number ProcessFile(FileString) Next End Sub Private Sub ProcessFile(ByRef FileString As String) Dim FilePath As FileStream = Nothing Try FilePath = New FileStream(FileString, FileMode.Create, FileAccess.ReadWrite) ...process Catch x As x ... Finally ' If file was opened and created, close it If (FilePath Is Not Nothing) FilePath.Close() End If End Try End Sub I left the check against "Nothing" in the finally since there's a chance that the file opening/creation failed and hit the Catch block. You don't want an exception in the Finally block while trying to call Close on a null reference. If you need to know if a file failed so that you won't continue looping, you can have ProcessFile return a bool indicating success/error and check that within the loop - or anything else you want. -ner
  16. My guess the problem was with the casting. The ternary can't resolve the left side (DBNull.Value, which is just "object") and the right side (an int). You'd normally have to cast the int as an object, to match the type of DBNull.Value. On a side note, if quantass is reading this, why would you pass myParentID when you're checking sectionUpdate.iSection.ParentID? Normally the tertiary operator is used just like you have it, but returns the value it's comparing. For example: Change ... = (sectionUpdate.iSection.ParentID == 0 ? DBNull.Value : myParentID); to this: ... = (sectionUpdate.iSection.ParentID == 0 ? DBNull.Value : sectionUpdate.iSection.ParentID); -ner
  17. On a similar note, I had an interesting discussion today with a friend over Linux vs. Windows - and not the typical "mine is bigger/better than yours" discussion, but a down to earth discussion. We're both developers and my friend was saying how he's been trying out Linux and mostly likes it. It's very fast to boot up, has most of the same features as windows and even has C# now, with Mono. He spent quite a bit of time learning all about it, including putting forth some effort into setting up his ATI card, which he said was quite a bit harder than an nVidea card. His bottom line was that while he liked Linux just fine, he was "ready to go back to Windows" where he could be more "productive." That is, he has a few games he wants to play that only play in Windows. He likes to write C# programs and, while there IS mono for linux, is it really worth the effort right now? Meaning, if you run into a bug while programming how likely is it that it's truly a bug with .NET vs something you're doing wrong? With MS and Windows I've gotten a pretty high "non-bug" factor history, when I stay on the beaten path of .NET. With Linux, there's no such history. In the end, he liked learning about linux but won't be keeping it around for most of what he does - it's just not feasible to reboot into Windows, then linux, etc. and keep up the level of knowledge he wants in both OS's. So, in light of that conversation, I still think that the Betamax vs. VCR is a great analogy. For me, it comes down to what you said - what does the average Joe want to use? Define "best" however you want, but I think most people would agree that a VCR was very easy to use and did exactly what it was intended for. I'd argue the same for Windows and the PC. For the most part, I've hard VERY FEW issues with any MS products - my games work, my applications work, the software I write works. Is Mac better? Define better. My definition is probably different. Because of the comfort factor alone, I'm vastly more productive in Windows than I am at Mac. Now, if Windows becomes hard to use then I'll consider switching. If Mac is the easiest thing on the block and yet so is Windows, I'll be sticking with Windows because it's what I know. I think MS has a pretty good track record of keeping things "easy", though TC may certainly ruin that if there are more and more roadblocks to using my PC. I certainly see a general trend towards making software HARDER to use (more dialogs, more options, more choices that I just don't care about), and I wash that weren't true. I love the fact the Apple created the iPod - that, to me, is the perfect design in that it's so intuitive that ANYONE can use one the first time they pick it up. If all software were that easy, then maybe the OS market would even out. I hope, in the end, that TC makes my computer experience "better." Now I gotta think about what "better" means for the next 5 years... -ner
  18. On a similar note, here's the latest commercial (for Mac) between PC and Mac (safe for all viewers): http://www.youtube.com/watch?v=JheuLfWYSsc Funny thing is, from my friends that have Mac, they say a Mac does the exact same thing (lots of popups asking if this site or download is Ok or "safe"). Vista takes the cake for the most, but like most of those messages, they're one time or can be disabled. With VS 2005 eating up about 2 gazillion bytes of RAM and Office taking up another few megazillion, I wonder how much better these new PCs really are. I was hoping that at SOME point, the PC would be waiting on me, not the other way around. What am I talking about? I'm talking about making my PC seem as fast as it says it is - no more popups slowing me down, bulky programs eating up resources that slow me down, etc. I want my 3.4gz dual core 2gig machine to act like that. -nerseus PS I'm in a bad mood after learning about the release notes involved in going to VS 2005 SP1 - we have every possible "alternate path" for the release notes, such as "if you have Vista, if you have 64 bit, if you use WAP,...". It's going to be NOT fun testing that.
  19. I whole-heartedly agree with the last line - there's NO point in writing documentation unless you know your intended audience. Write it from that point of view. For simple C# method/class comments, you might try out Ghost Doc. I absolutely love it, especially for well named methods and parameters. http://www.roland-weigelt.de/ghostdoc/ I also like to have a folder in each assembly called Documentation. I generally have at least a readme.txt and possibly a few word docs. I like to have about one to three pages of high level "here's what happening in this assembly and the important classes" type of documentation. Even for UI assemblies this helps. I gear that documentation for a developer who has been with my company for a year or so and knows their way around, but may not know didly about that assembly. I also try to think about what I would want to see if I didn't touch the code for a year or more. If there are any particular "weirdnesses" or debates about a particular decision (should this class store it's data in variables or a DataSet, for example), I like to document the choices and my reasons for choosing one. I never quite remember why I went one route later on and I think "the grass is greener on the other side" and want to switch, only later to find out that I did have good reasons for going one route vs the other. -ner
  20. I did some googling and got mixed results. I couldn't tell if people found a way to do it by changing their current thread's uiCulture or not. Someone pointed to the following website, but I can't contact it - I keep getting "connection" problems in IE though all other pages work. Might be worth it if you can reach it: http://www.iranasp.net/ I'm not that familiar with the various 3rd party tools that are out there. If there's no built in way to get the calendar to switch, you may be able to buy a custom control. -ner
  21. Is it possible that between the Brand and Hierarchy elements there's a special character, maybe character(0) in the string? I'm wondering if there's something that may be triggering an end of file unexpectedly even though the string "looks" good. Can you save the string to a file and try to open it with XmlDocument? I usually prefer XmlDocument to the streaming object since it validates the "easy" stuff (like missing elements or closing elements, etc.) while it loads the document. As long as it's relatively small (even a few megabytes) the XmlDocument is lightning fast. -ner
  22. I haven't heard much about TC before, but it sounds interesting. I like the idea of DRM, as long as it doesn't make what I do on the computer harder. Computers are hard enough for people to understand. Trying to make them more secure is a very good idea, but if that makes it harder to understand then it would only seem to incite more distrust. So I have two views: mine and my parents. I'm 35 and a very knowledgable "computer guy" - heck, I still think it's fun to build my own computer (though I'm getting closer and closer to giving up and buying a big box store computer). My parents are the opposite - my mom (59 now) actually cried when her boss told her she'd have to learn to use a laptop or resign. But she knows enough to look for the "lock" icon in IE when shopping online. I think things like TC, if implemented nicely, will make computers easier to use and more trustworthy. The problem is that it almost NEVER works out that way. In an attempt to make things more secure, I get more popups than ever when downloading software and even I don't read the popups explaining what's what. I can't imagine what my parents would do with a "do you trust this certificate" popup. The average joe just doesn't want to have to care about that nonsense. My take is that people are getting sick of computers that are hard to use. Computers are faster than ever yet they slow us down at every step of the way. People want an ipod - plug it in and it works. Simple. They want a computer they can trust, where they can shop online witout worrying about getting their Credit Card number stolen or getting identity theft. If TC is easy and doesn't make computers harder, I'll buy into it. If I ever get stuck and can't do something I want to do, I'll b* and moan about TC everywhere and fight it tooth and nail. I don't hate it on principle, but man oh man, don't make me buy a CD and then say I can only rip it once. I'm going to fight that big-time. In the end, I would guess this may turn into something akin to Beta Max vs VCR - the general public will move to whatever they prefer and their preferences can definitely be swayed. But if TC is the big push and it makes things harder, it may just turn into Microsoft Bob all over again. -ner
  23. I believe you'll want/need to create a license - I've never done this, but seen it done by 3rd party vendors. Here's an article on MSN that may help point you in the right direction: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconlicensingcomponentscontrols.asp -ner
  24. If you didn't already know, what you're doing is generally called "lazy loading" or similar. The idea is only instantiate the object when it's needed. Thought I'd throw out that term in case you found it useful in google searches. -ner
  25. Can you give us a clue as to what else you know/need? Do you know about ADO.NET, how to make a connection to a database? Do you know how to read a text file to parse it - presumably one line at a time? Is this just for fun, or a production application that needs lots of error handling? -ner
×
×
  • Create New...