Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. Is there supposed to be an underscore in the Data Source part of your connection string? -nerseus
  2. In C# I get "Use of unnasigned local variable DS" (I converted his code, but it was mostly the same). I'm not sure if VB.NET checks for this or not...? -nerseus
  3. I'm not sure if you can change the Collation (or anything equivalent) in Access, but you can use the StrComp function to do binary compares (case-sensitive): -- Below will match "hello" but not "Hello" or "heLLO" SELECT * FROM Table1 where StrComp(test, 'hello', 0) = 0 -Nerseus
  4. Strict != Simpler Coding :) I still prefer strict (the only way to go in C#). I used to get aggravated at not being able to use Enums as ints without casting, but I got over my issues and learned to do it the "right" way. Of course, "right" is a per-user setting (or per-office in some installations :)) -Nerseus
  5. Well the first code you posted shouldn't even compile since you never create DS (by setting it to a New DataSet()). -Nerseus
  6. With a default installation, all columns in SQL Server are not case-sensitive. This is set by Collation and can be overridden. For instance, on your USERS table you probably have the collation set to SQL_Latin1_General_CP1_CI_AS. Check it by using Enterprise Manager, right click on the table and select Design. The last property for a column will be the collation. All values that have "...CI..." are case-insensitive. So change SQL_Latin1_General_CP1_CI_AS to SQL_Latin1_General_CP1_CS_AS and your usrPassword column will be case-sensitive. -Nerseus
  7. Is the machine just a terminal-service enabled computer, or do you mean you are using terminal services to connect remotely to another machine and through that connection, trying to run a program that is trying to kill a process? Did you try the overload that takes the machine name and try and run the program for your client machine and connect to the remote machine (instead of connecting through terminal services and running the program locally on the remote machine)? As long as the user you are connecting as is an admin on that machine, I wouldn't think you'd get an Access Denied message. Is that machine on the same domain as the Domain Admin you're connecting as? Meaning, are you connecting to a machine on another domain? Have you tried logging onto the remote machine as a local admin (local to that machine)? -Nerseus
  8. Regular expressions are great (didn't Robby or Orbity put together a sample for them?). You can also set a TextBox's MaxLength property to limit them to 10 characters (hard-and-fast limit - not an "after the fact" type of limiter). I was mentioning the Parse method's overloads because they're useful elsewhere (such as for a Format/Parse event on a Bound control). A simple regular expression such as "^\d{0,10}$" should do the trick. It won't allow the user to type in "10,000" though - it will evaulate false. You can always tweak the expression to allow commas, a decimal point and more, but there are built in NumberStyles for those already (but you can't use them with regular expressions). Ah well, I wonder if there are more ways to validate numeric input than there are number of licks to get to the center of a tootsie roll tootsie pop... -nerse
  9. Also, the Parse method allows you to specify what a valid number looks like, such as whether you want to allow a thousands separator, a decimal point, and more. There are some built-in types such as "System.Globalization.NumberStyles.Number" and "System.Globalization.NumberStyles.Integer". Here's a revised version of Volte's function that specifies what a valid number will look like: Private Function IsNumber(ByVal str As String) As Boolean Try ' I hope my _ syntax is still valid in VB.NET... Integer.Parse(str, _ System.Globalization.NumberStyles.AllowLeadingSign Or _ System.Globalization.NumberStyles.AllowLeadingWhite Or _ System.Globalization.NumberStyles.AllowThousands Or _ System.Globalization.NumberStyles.AllowTrailingWhite) Catch ex As Exception Return False End Try Return True End Function I also got rid of the dummy int variable. It wasn't being used and isn't necessary to get the Catch to work. -ner
  10. About 10 posts down is this thread. Covers the same question you have. -nerseus
  11. Assuming you're bound to a DataSet, use the DataSet's WriteXml method. You can read it back in with ReadXml. -ner
  12. I'm not sure of the direct correlation between RGB and the Hue/Saturation values, but here's a trick I've used in the past with good results. From each color (say red, which is r=255,g=0,b=0), increase all 3 values by a certain amount, with a cap of 255. For example: // untested, but hopefully working :) int increaseVal = 20; // Arbitrary value, depending on how "light" you want to make your new color Color r = Color.Red; Color new = r; new.r = Math.Min(255, new.r + increaseVal); new.g = Math.Min(255, new.g + increaseVal); new.b = Math.Min(255, new.b + increaseVal); While the Color type supports an alpha, it's not used (for the most part) for coloring controls. Don't try tweaking the alpha hoping to get a brighter or darker color. -Nerseus
  13. Neither Hide() nor setting Visible=False will work with TabPages. You can remove them through the TabControl's Controls collection or the TabPages collection using the Remove method. For example, use one of the two lines below (they do the same thing): tabControl1.TabPages.Remove(tabPage2); // OR tabControl1.Controls.Remove(tabPage2); Keep in mind that if you want to add the tabpages back in later, you have to add them in the order you want them. That may mean removing them all and adding them back in one at a time. -Nerseus
  14. I actually wrote one for our old web applications that stored the help in an XML file. It provided everything normal help did and without the need to convert the whole thing to an Access Database when doing a find. Our QA team *loves* it (but what do they know? :)) Maybe I should try and sell it to Microsoft, just so that all the previous help file formats are depricated. :) OT: I wonder if MS ever tried to buy Robohelp - they integrated MS Word with their own help compiler, something I'm surprised MS didn't try to do first.
  15. The short answer is, you can't. If you just want to save the two values, then why not create a table with an "int" column and a "bit" column? Usually, you have your tables defined first, then create your code structures to match, not the other way around - though your case may be special. If you want to create a new structure on the fly you'd have to issue a "CREATE TABLE..." command? That would require dbadmin privileges to create tables in the database you're connected to. The user-defined-datatypes in SQL Server are nothing more than alias's for built-in types. You can't really have a user-defined-type made up of two types of values (such as int and bit). -nerseus
  16. There's an easier method to determine dupes in a DataSet. It might not be as speedy as other methods, but it's easy to understand AND code. First, create a DataRow array using the DataTable's Select method with a sort on the Primary Key or Keys (depending on whether your table's "duplicates" are based on one column or more than one). Loop through each row starting at the second row and compare the same column(s) to the previous row. If they match, then they're duplicates. Here's some sample C# code (untested). I assume the PrimaryKeyCol is a string (hence the ToString method below). If your primary key column is an ID, cast the column as an int or whatever you need: DataRow[] dupes = ds.Tables["DupeTable"].Select(String.Empty, "PrimaryKeyCol"); for(int i=1; i<dupes.Length; i++) if(dupes[i]["PrimaryKeyCol"].ToString() == dupes[i-1]["PrimaryKeyCol"].ToString()) // There's a dupe at index i -Nerseus
  17. Ah, didn't test my code far enough - only first the Activated event on the child form the first time the first instance is shown. Never fires again. You can use the ActiveMdiChild property of the MDIParent form to get the active child form. Since you're accessing this in the MdiChildActivate event, it should be the one that's receiving focus. I tested with the following code and it worked like a charm. Of course, I only show Form2 as a child - if you have different child forms, you can't use the direct casting as I've done here. private void Form1_MdiChildActivate(object sender, System.EventArgs e) { Form2 f = (Form2)this.ActiveMdiChild; MessageBox.Show(f.Handle.ToInt32().ToString() + ": " + f.Text); } -Nerseus
  18. Whoops, thought you just wanted zipping. Try this link instead. -Nerseus
  19. I'm confused... did you get this resolved by updating a printer driver, or are you still having the problem on Win 98? -Ner
  20. Try here -ner
  21. I have NO idea. Maybe someone else knows? -Nerseus
  22. I've used other forums where the post count (the one below a person's name on each post in each thread) reflects the post count at the time of the post. On this forum it always reflects the highest value - so if I go back and read my first message it might say "Posts: 100" instead of "Posts: 1". The other forums look like they're using the same software to run (same basic options, look and feel, etc.) so I wondered if it was an option. The argument for showing the actual post #: don't have one, I just like seeing which post # it is :) The argument for NOT showing the actual post #: nothing has to change and we can all go back to answering important questions. -Nerseus
  23. I've used control arrays at design time and runtime. The only thing missing is control arrays at design time. Their benefit? Being able to set known indexes at design time and position them to their exact location. Then you can write looping code against those controls easily. To mimic this in VS.NET, you have to create control arrays at run time and position them manually - not that hard, but nearly as convenient as using the designer. If you already wanted run-time control arrays then you're in luck as they're just as easy in .NET as VB6 and lower. -nerseus
  24. If I'm not mistaken, the CArray type is a template class not a true class. It means you have to create your own class based on your datatype - in your case a double. I thought you had to first do something so that the compiler knows you want one based off of the type double. Most of the standard data types have already been implemented as their own types, based on the CArray type. For instance, there is a type called CWordArray. Check out this link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_collections_topics.asp At the bottom is a section of "Further Reading" including a link to making your own type safe collection I'm far from a C++ programmer though, so this may not be what you want/need :) -Nerseus
  25. Be careful when you call Dispose() on a Graphics object. Cywizz, your example is not creating the Graphics object and therefore shouldn't Dispose of it. Only when you create one through CreateGraphics should you Dispose of it. -Nerseus
×
×
  • Create New...