If you are using a DataAdapter to fill you dataset you can always create a strong typed dataset which allows you to access the data as:
dsMyStrongType.MyStrongTypeRow dr = myDs.MyTableName[row];
dr.MyField = something
Makes life a lot easier and less apt to have typos on field names (plus you get Intellesense). Just build your DataAdapter in the editor and the right click on it to generate a dataset. If your stored procedure returns multiple results it will build a table by name for each. You can also select the table mapping property to call the tables anything you like.
When using DataSets, try designing a strongly-typed DataSet by using the DataSet designer in VS.NET (there are other ways and tools, too, but I present the way in VS.NET). Right-click on your project or subfolder and select Add New Item. Find DataSet, give it a name, and click OK.
You'll see a component designer screen. Right-click to add elements (tables) and each element has rows and their types (the columns). You can even add relationships and primary keys. Just play around with it a little.
You can even use the Server Explorer if you have a database connection to drag-n-drop tables or stored procedures which returns tables to generate these automatically.
When you fill the strongly-typed DataSet, your DbDataAdapter derivative (like SqlDataAdapter) has to be configured to map the tables. This is done through DbDataAdapter.TableMappings and can easily be configured by using the data adapter designer in VS.NET as well.
Finally, you don't even need to use strongly-typed if you use the TableMappings property mentioned above. When selecting multiple result sets, the sequence of table names is "Table", "Table1", "Table2", etc. If you map these to other names, you can use DataSet.Tables["nameOfTable"].
I recommend using strongly-typed DataSets, though. You can easily refer to columns by name and don't have to worry about casting since those named rows return the appropriate Type.
I must have just skipped by it, but when I was checking out the 'switch' keyword, I noticed that C# has a "goto case" fucntionality inside of a switch block to go to another case statement. Not that I would have a need for it often, but if I do it is there
Funny thing is though, since moving to .NET I seldom use switch. Just have not had a lot of need for it.
Set the TabIndex of the control you want to have initial focus to 0, adjusting the other controls with TabStop enabled. You can do this easily in VS.NET by click the View->Tab Order when a form is open in the designer.
The Focus method only works when a control (including a form) is already open.
By setting Index equal to 8, you're starting your backward search at index 8 and working backward, so there is no instance of @"\\". String.LastIndexOf - if provided a start index - will begin searching from there and search backward. See the documentation for String.LastIndexOf in the .NET Framework SDK for more details and pretty thorough example.
How can I convert a DateTime variable to double time representing time as a modified Julian date?
Modified Julian date
Time is represented as a modified Julian date. A modified Julian date is the Julian date minus 2400000.5. A modified Julian date represents the number of days since midnight November 17, 1858 Universal Time on the Julian Calendar. A modified Julian date is chosen instead of the (unmodified) Julian date because the numbers become smaller and also higher precision in representing time is possible. Julian dates are often used in hydrology.
I am trying to write a windows service to monitor activity on the serial port. I can write a simple service, but I am not sure how to monitor the serial port. I was wondering if anyone out there knows how to monitor the serial port in a service. Any help would be appreciated Thanks Tim
Right, i am having 1 of them shouldnt have got up days, so this is probably a real simple question.
i have created a base form that has an IE object and a few buttons on it, i then create a new form that inherits from this base form. The code compiles fine and when i run the app the inherited form shows ok and i can click the buttons etc. But when i view the inherited form in studio at design time the form does show and i get the error message "The path is not of a legal form".
Eh? Where have i gone wrong, what path is wrong?
Senior Software Architect
National Energy Services Ltd
Visit Us: www.nesltd.co.uk or: www.nher.co.uk
The designer can be pretty finicky at times. In order to create an inheritted form that VS.NET likes, right-click on your project and click Add Inheritted Form. You're project will have to had been built at least once with the form from which you want to inherit. If you want the new form to be able to access controls on the inheritted form, click on the controls in the original form and change their access modifiers in the PropertiGrid to protected or public.