Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. I don't know if many people know about this, so I thought I'd throw it out there. If you hold down Alt while dragging the mouse over a text selection in VS.NET (or hold Alt while using Shift-Arrows), it will do a BOX selection. In VS 1.0 you had to double click on the status bar where it said "STREAM" to switch it to "BOX". This doesn't exist in VB6 or prior. So what is BOX selection? It means the usual highlighting of text is a rectangle rather than selecting from a start to and end point which includes all text on every line in between. It's probably easier to try it yourself than for me to explain it :) One other "cool" feature of VS.NET: Last/Next Position. If you press Ctrl-"-" (Ctrl plus the minus key), it will jump to the last place you had the cursor. VERY useful for returning to code you looked at previously, especially after a "Goto Definition" jump. As a side note, I use a MS Explorer mouse. With Intellipoint 4.0 software (free from MS), you can define keystrokes to mouse buttons, per EXE. I have defined the mouse-wheel button (not scrolling, but the click) to Ctrl-"-". I pretty much never use the middle mouse button since the mouse wheel does the up/down scrolling. By reassigning this, I can easily jump backwards in code to see where I've been. I also assigned Ctrl-Shift-"-" to the right-side button (I have a 5 button mouse with the Forward/Back buttons on the side), so that I can move forward through code as well, to get back to where I was. It's been extremely useful when looking at a couple of pieces of code - I find using the code splitter bar to be more trouble than it's worth for the most part (though useful in some scenarios). Just thought I'd share this with everyone. -Nerseus
  2. Even VB6 has it's limitations on what you can change at runtime. I'm sure MS will provide a list of what can/can't be changed at runtime. But changing some simple things like commenting out a line or changing a literal (4 to 5, for instance) will probably be allowed once they add the edit-and-continue. I'm not holding my breath, but I will be glad if/when it comes :) -Nerseus
  3. If you plan on saving this data to a DataBase as an Identity column you shouldn't have to worry - the number in the DataBase will override whatever is in the DataSet. So even though you show "1" and "3" the database may substitute "467" and "468". If you are using the AutoIncrement as a pure sequence for the current data only, then you shouldn't use AutoIncrement but use TechnoTone's advice and make it a regular number. You'll have to manually change the number as rows are added/deleted. During a Delete of a DataRow, you'll have to grab the current value, loop through all rows that are higher numbered and decrement their number by one. Well, that's one way to do it anyway. The point is that you'll have to do it manually :) I'm not sure what TechnoTone means with the "UPDATE myTable..." since I don't know how you'd execute this "query" against a DataSet. If you had already saved it to a database, maybe - but I'd think you'd want to change it before it got saved to the DB. -Nerseus
  4. Ah, I didn't look close enough at your usr_Get_Fehler proc. You can't assign a string like you are with: EXEC @Fehlertext = usr_Get_Fehler 3 You'll have to use an output variable, as in: CREATE PROCEDURE [dbo].[usr_Get_Fehler] ( @Fehler INT, @NVC_Fehlertext NVARCHAR(250) output ) AS SELECT @NVC_Fehlertext = NVC_Fehlertext FROM tbl_Fehler WHERE I_Fehler_ID = @Fehler --From within a proc, use the following: -- dataset does not exist ELSE BEGIN EXEC usr_Get_Fehler 3, @Fehlertext output RAISERROR (@Fehlertext,16,1) RETURN 3 END END -Nerseus
  5. I should have mentioned that I have one form to handle a large transaction. It contains 9 tabs, all have mostly just grids but one tab has about 30-40 controls. We use a number of custom controls for DateTime and Number fields in addition to custom grids. It used to take about 10-15 seconds to show the form in the designer (just double-clicking the form), it now takes about 3 or 4 seconds. While my wife thinks I'm inpatient because I told her the 15 seconds was "too long", it really is a *long* time to wait for something so simple as tweaking a UI control. It also makes running the program/debugging more difficult because it takes over a minute to get to the point where the form is loaded in the correct state to test (mostly a lot of searches and what-not to get there). If you have large forms or large projects, a faster machine is well worth the investment. I used to find myself distracted since, as I said, it took over a minute to get to the point where I could prep the form for debugging. I'd check/send an email, etc. while waiting, but it just spread out the time to debug. Not a good idea... Of course, if MS ever puts back in the edit-and-continue (with the changes), this may help stop this. It's the one thing I miss about VB6 and prior. -Nerseus
  6. Again, it's not good or bad to do anything if it's needed. But you probably don't need very many static variables, in general (I've never had the need for more than 2 or 3). Static methods only take up the memory for the compiled instructions of course, just like any other code. I don't remember offhand how the garbage collector treats static variables - I would imagine it treats them like any other chunk of memory. -Nerseus
  7. Use clrdlg.Color.ToArgb().ToString() or something similar... (don't have the exact method names in front of me). When reading them back in, use Color.FromArgb(Convert.ToInt32(registry value)) -Nerseus
  8. Nah, in fact, bigger companies probably have more time to study than smaller companies and especially freelancing (where you only get paid for work related to your job). But with freelancing you're hopefullying making a LOT more money so that you can take a month off every now and again to study, catch up, etc. Or at least that's the idea behind making more money. Some smaller companies (my current one for instance) do provide "free time" but it's also expected that you do some learning on your own. Most places will buy you basic studying items such as books or online resources. Bigger companies generally have bigger budgets so you may have a better chance of attending those $2000 MS sponsored training sessions. Then again, they may have a lot of employees and can only pick a few to go and come back to teach the rest. The interview process really is more than just trying to GET a job, it's to find out if that particular job is a good fit. At least, it should be :) -nerseus
  9. Not so much disadvantages as just differences. A static method is like a global function. A public method is intended to do some action on a specific instance of a class. So a Car object might have a method named Start() but you wouldn't make it static because you only start a specific car (for example). The DateTime object has a static method IsLeapYear(int year) that returns true or false whether the year is a leap year. It's static because you don't want to have to create a DateTime object just to call that function. Whether your objects have static or just public methods is entirely up to you - it's just whatever makes sense. -Nerseus
  10. Do you care what kind of programming you'll be doing? Do you like web, windows, html vs. a compiled language, etc.? Do what the college kids do and just apply anywhere that sounds interesting... You may also want to check out temp agencies that specialize in computers (not necessarily Manpower USA for instance). In my area there's one called Tad, another called HL Yoh, and more. They usually have free resources to learn anything you want (classes on CD type of things) plus access to the computers if you don't have one. You always have the option of saying No when they offer you something - you're under no obligation. They tend to give you anything that comes along since they make no money if you're not working but you don't have to do data entry into Excel unless they talk you into it :) Just some ideas. Check out the following threads for slightly similar information: http://www.xtremedotnettalk.com/showthread.php?s=&threadid=69501 http://www.xtremedotnettalk.com/showthread.php?s=&threadid=69345 http://www.xtremedotnettalk.com/showthread.php?s=&threadid=69304 http://www.xtremedotnettalk.com/showthread.php?s=&threadid=69296 -nerseus
  11. Don't forget that every other 1000 years is NOT a leap year though it is evenly divisible by 4. So 1000 mod 4 = 0 but 1000 is not a leap year (2000 is, 3000 isn't, etc.) -Nerseus
  12. "global" classes can have their uses for reuse. They can do anything you need, but combing a few lines of code into a function can make your work a little easier. In C# (in VB, too), you can declare classes with static/shared members that are the equivalent of modules in VB6 and earlier. For instance, I had the need to calculate the number of months between two dates. I use it in many places so it doesn't really belong as a method of a particular class. Plus, I don't want to have to instantiate an object just to use the function. Here's how I did it in C#: public sealed class DateFuncs { // Private constructor - can't create class private DateFuncs() { } public static int MonthDiff(DateTime startDate, DateTime endDate) { return ((endDate.Year - startDate.Year) * 12) + (endDate.Month - startDate.Month); } I chose to make the class sealed (can't inherit from it) and the constructor is private so no one can instantiate it. Marking the method as static means I can use it with: int diff = DateFuncs.MonthDiff(date1, date2); Just about every type of code has its uses, even modules. I think the consensus is that a module isn't necessarily going to be around forever but the equivalent "global" type of functions are still of use, just work differently in .NET. Just a matter of learning what to use instead :) -Nerseus
  13. I assume you can't use DateTime.Parse(...) either? I believe the "IsLeapYear" function checks the following: if(year is evenly divisible by 4 and NOT 0, 1000, 3000, 5000, etc.) leap year! else not leap year! Since this seems to be an excercise, I'm not providing the details just the info :) -Nerseus
  14. For the record, I tried using an expression column to automatically convert the string (FF00FF00) to a Color but it didn't work. I also tried using the Parse/Format events but you can't define them until AFTER you've added a DataBinding to a control - which won't work because of the original error. I'd be curious to know if you can find a more automated approach to the conversion between your database field and the Color object for binding. I haven't had the need yet, but it might just be a matter of time. -Nerseus
  15. I'm not sure what you're trying to do exactly, but it looks like your SELECT is only returning one table (using joins will still bring back one table's worth of data even though it's using multiple tables). You execute your DataAdapter's Fill method twice, but it's not going to fill each table. I think what you want is to have two separate SELECT statements and create a DataRelation between the two (in code) similar to your INNER JOIN in your SQL. The DataAdapter doesn't recognize SQL joins - it treats them as a SELECT from one table. Let me know if you need help piecing things together... -Nerseus
  16. I know you can do this in SQL Server with no problem. When you create your DataAdapter's sql string, you just put in multiple SELECT statements or use a proc that has multiple SELECT statements. I'm not sure if Access will allow this or not, but I think it will. I'd give it a try - start with two tables and separate each SELECT with a semicolon (I think that's what Access uses). SELECT CarID, Manufactore, Colour, Hp, Displacement, Price, Mode FROM Car; SELECT SaleContractID, CarID FROM SaleContractCar Let me know if this doesn't work - I don't have Access installed right now, but I can get it on pretty quick. -Nerseus
  17. Not sure how you'd get the return value "RETURN 1...", but you may not need it. I usually use the state parameter of RAISERROR to indicate any special value (you used 1 in your sample). You can get the values you need from the SqlException object. The number will always be 50000 unless you define your own error and raise it instead (with RAISERROR (50001, ...)). Here's a sample: // Assume the RAISERROR looks like: RAISERROR ('Hello World', 16, 1) // The code looks like: catch(SqlException e2) { Debug.WriteLine(e2.Number); // Shows 50000 Debug.WriteLine(e2.Message); // Shows "Hello World" Debug.WriteLine(e2.Class); // Shows 16 Debug.WriteLine(e2.State); // Shows 1 } // Assume the RAISERROR looks like: RAISERROR ('Hello World, string=%s, number=%d', 18, 21, 'bob', 42) // The code looks like: catch(SqlException e2) { Debug.WriteLine(e2.Number); // Shows 50000 Debug.WriteLine(e2.Message); // Shows "Hello World, string=bob, number=42" Debug.WriteLine(e2.Class); // Shows 18 Debug.WriteLine(e2.State); // Shows 21 } -Nerseus
  18. It's not so simple... To bind a property to a DataSet's column, the types must be equal. There is no equivalent database type for .NET's "Color". I tried a couple of things to work around this, but the closest thing I found was the following. It adds a new column to a datatable and manually converts the data in the dataset from the database's native type to a Color object. My database table has a column LastNameColor defined as varchar(8) (8 characters). It has values like "FFFF0000", "FF00FF00", and "FF0000FF". // Add a new column named LastNameColor2 to the table. // It's datatype is Color ds.Tables[0].Columns.Add("LastNameColor2", typeof(Color)); // Loop through all rows and convert the column LastNameColor // from the "FF00FF00" value to an int // Then convert that int to a Color to store in the LastNameColor2 field foreach(DataRow row in ds.Tables[0].Rows) row["LastNameColor2"] = Color.FromArgb(Convert.ToInt32(row["LastNameColor"].ToString(), 16)); // Finally, bind the ForeColor property to the new LastNameColor2 field txtLast.DataBindings.Add("ForeColor", ds.Tables[0], "LastNameColor2"); -Nerseus
  19. For reference, I upgraded from a PIII 700 w/ 384meg ram to a P4 3ghz w/ 1gig ram - made a WORLD of difference. At home I had a PIII 733 w/ 512 meg ram, ran about the same speed so I assume it's not necessarily memory (but more always helps) but a good CPU as well. .NET sure isn't VB3... (1 to 3 floppies :)) -Nerseus
  20. Another consideration is how often/available the historical data needs to be seen. If you don't need to dynamically query the historical (audited/logged/etc.) data, then using something like XML might be an option. Simply store snapshots of data to a single table. We use this approach in some situations - in conjunction with a Database name, Table name, and primary key value (all of our tables use identity columns). If someone needs to view the historical data because of some issue, it's a manual process that involves someone with database knowledge to extract the data. It works out well in some instances, where you don't need to query the changes. Using the same table for historical data poses some problems, such as having to always find the most current or "active" record but is also a very common auditing approach. Of course, any form of auditing is going to effectively double your database size (at a minimum) - either through double tables, or double data. -Nerseus
  21. I'd think that if you don't even know what language to use, you shouldn't be writing a game, especially an RPG-style. especially an "RPG-style" game. I'd learn some basic programming, then maybe code a game that says "pick a number between 1 and 10... higher... lower... higher... you got it!", then move onward... :) -Nerseus
  22. I assume you're writing all the SQL by hand - you're going to have to add code (manually) to include extra INSERT commands to save off the changes. Since this will have to be done manually, it's up to you to decide what you want. I'd check with your clients to figure out excactly what they want stored. Some common options are only changed records but some may want the entire row saved off. More likely (hopefully), you may only have to audit/log certain tables... but this is a design issue, not a programming issue. Check with your clients before you touch any code :) -Nerseus
  23. You should use the following. You don't need the "If" While DataRead.Read cbCompList.Items.Add(DataRead.Item("competition")) End While According to the Help, the DataReader begins before the first record. The first call to Read advances the pointer to the first record but only if it exists. If it doesn't the Read method returns false and you'll never get in your While loop. -Nerseus
  24. To get the popup window, you'll want the ShowDialog method of the form. To get values back, simply expose what you want as a public field on your popup form. For example, assume you have Form1 (the main window) and Form2, the popup. Also assume you want to expose the selected row as a DataRow on Form2, so that Form1 can display the data that was selected. Here's what Form1 might look like (maybe this is in a button click event or somesuch): Dim f2 As Form2 = New Form2() f2.ShowDialog() 'The following line will execute once Form2 has been closed If Not f2.SelectedRow Is Nothing Then 'They selected something, assign it to a local variable, dr 'dr would likely be stored at the form level, as a private DataRow variable dr = f2.SelectedRow End If The following chunk is in Form2: 'At the top of the form: Public SelectedRow As DataRow 'In the Double-Click event or a Select button's click event Me.SelectedRow = ... 'Select the Row from the grid and assign it here Me.Close() 'In the Close or Cancel button, if you have one: Me.Close() ' Nothing special, SelectedRow will default to Nothing -Nerseus
  25. With few exceptions, you do nothing special when the user presses the "x" to close a window. You may trap the Closing event to pop up a message to the user, such as "Are you sure you want to Close?". The applications I've seen that use the "x" to minimize to the tray are definitely exceptions, such as WinAmp or an instant messenger. If you're coding something similarly complex, I'd get a good understanding of the language before proceeding. If it's a standard Windows app, the "x" just closes the form, something that happens automatically so you won't need any code. -Nerseus
×
×
  • Create New...