The first thing we need to do is to create the actual dataset. There are a number of ways to accomplish this, however I have found that the most straightforward way is to right click your solution, select Add… then select Dataset from the list.

Datasets can contain many tables or queries or both, I tend to create a dataset per table unless I need to work with joins or multiple tables at once.

There are also a number of options involved in creating a dataset, we are going to explore several of them in this series. The most significant decision you will need to make is whether or not to base your dataset on Stored Procedures or Queries.

In this first example we will be using Queries. But first we need to create the dataset. Once you have selected Dataset you should give it a name, I typically use the table name it is going to be based on, in this example, Employees.xsd

The Dataset Designer will appear, a mostly blank screen that we will drag objects from Server Explorer onto. Go to the Server Explorer window, if it is not visible you can pull down the View menu and select Server Explorer. You should see something like Figure 1: Figure 1.

The Data Connections node is what we are going to work with, right-click it and select the Add Connection… option. Fill in the resulting dialog to connect to your instance of SQL Server and make sure the database selected is “pubs”.

Expand your connection and you will see a listing like Figure 2: ServerExplorer2

As you can see we now have access to a number of items within the database itself, most importantly for this example, the Tables node.

Expand the Tables node and drag the ‘employee’ table onto the dataset designer surface. By default you will get an ‘employee’ dataset and an ‘employeeTableAdapter’ with two methods, Fill and GetData().

Behind the scenes a great deal of code has been generated for you, or will be once you press Save. But we don’t want to accept the defaults, so we are going to make some adjustments.

The first thing you should know is that the process of dropping the table onto the designer surface persisted the connection you created in you applications app.config file. It will have created the app.config file if one did not already exist.

In a production application you would want to alter this connection string to match the production servers connection parameters as well as probably encrypt it. For this example I would suggest that you open your app.config file and rename the connection to “pubs”. My ConnectionStrings section contains the following:

    <connectionStrings>
        <add name="pubs" connectionString="Data Source=DELLXPS;Initial Catalog=pubs;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>

I will show you later how to use this renamed connection string as opposed to the one the dataset will be expecting, and explain why I do that.

Next, we need to tweak some of the defaults created for us by the designer. Right-click the employee Dataset and select Configure from the context menu.

You will see a TableAdapter Configuration Wizard pop up. It will show you the query it is using to build and populate the dataset. Click the “Advanced Options…” button and make sure all 3 checkboxes are checked. They usually are by default. The first option tells the designer to create Insert, Update and Delete statements that match the Select statement used.

The second option tells the designer to Use optimistic concurrency which adds intelligence to the Update and Delete statements to allow them to detect if the record(s) they are about to Update or Delete have been modified since they were populated.

The final option, “Refresh the data table” fires a Select after every Insert and Update statement in order to retrieve calculated fields, default values and identity values that are generated by the database.

Once you have done that, return to the Wizard and select Next, you will get the Choose Methods to Generate screen. You will see 3 options, the first two are what we are concerned with for now.

All 3 should again be checked, modify the names of the methods to better reflect what they are doing, in this case returning all employees. See Figure 3 below for an example:

MethodsGen1

Press next once more and you will get Wizard Results screen that shows that the designer has generated all the code, queries and methods we asked it to.

Review the results, then press Finish to return to the designer. Your dataset should now look something like this in the designer:

ModifiedDatasetNotice the highlighted section, this shows that the method names have changed like we wanted.

Thats it! You have now created your first strongly typed dataset.

Next up, we will discuss what exactly this does for you, and how you would use it in code and what advantages you gain from using this construct.

Stay tuned!

Bob Porter

 


 
Categories: .NET | ADO.NET | Programming | VB.NET | Visual Studio | XML


November 28, 2006
@ 11:11 PM

This post is my first attempt to share some of my own experience. Specifically with ADO.NET and Typed Datasets. Scott Guthrie published an excellent series of tutorials on creating a DAL using Typed Datasets.

This is not an attempt to duplicate that series, but it is inspired by it. And I also wanted to do this from a Winforms perspective rather than an ASP.NET view, since I still work in both worlds.

For my first effort, I created a fairly simple application that allows the user to perform simple, Select, Update, Delete and Insert operations against the SQL Server sample pubs database employee table.

SQL Server 2005 does not ship with the pubs or Northwind databases any longer. If you want the scripts to create them you can download them here. These scripts while designed for SQL Server 2000 worked just fine in SQL Server 2005 and created the databases and populated them with data. (They also include pre built databases in the form of MDF and LDF files that you can attach but I prefer to build them from the scripts.)

If you want to download the sample application that goes along with this series of tutorial posts you can do so here. File Attachment: MasterDetail001.zip (71 KB)

I am going to begin this series in earnest tomorrow with the first of the “meat” posts. And let me clearly state, the code in the sample app is very basic, little or no error handling, and not necessarily even the correct way of doing things. I am looking for constructive feedback myself. This application, as it grows, and the tutorials that accompany it are as much a learning exercise for me as anything else.

Cheers,

Bob Porter


 
Categories: .NET | ADO.NET | Programming | SQL | VB.NET | Visual Studio | XML


November 20, 2006
@ 09:17 PM

There is a new Create-a-Character flash game on the South Park Studios site. My kids showed it to me today. I could not resist, here is the South Park version of me!

BobSouthPark


 
Categories: Misc


I recently ran into an issue where I needed to change the local instance of SQL Server 2005 from the Standard Edition to the Developer Edition. This was so I could install the latest version of Team Edition for Database Professionals which is currently at the CTP7 release. You can download it here. More about this fantastic new tool in a later post.

The tool requires either the Developer or Enterprise editions of SQL Server. And I had Standard Edition installed. I felt slightly ill at the prospect of uninstalling SQL Server and re-installing the Developer Edition, re-importing all my databases and the rest of the overhead involved. Surely there must be a better way! And there is!

Note: Microsoft has a great KB that helps you determine your SQL Server version and edition here so if you are unsure what version and edition you have check this article out for how to determine for yourself. For my version (2005) I ran the following query: SELECT  SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')

It turns out that you can indeed “Upgrade” from one SQL Server Edition to another via the foresight and magic of the SKUUPGRADE command line parameter. I inserted the Developer Edition CD, opened an command prompt and typed the following command line in:

start /wait setup.exe ADDLOCAL=SQL_Engine INSTANCENAME=MSSQLSERVER UPGRADE=SQL_Engine SKUUPGRADE=1 /qb

You can replace the /qb with /qn if you want a silent upgrade but then you will need to check the install logs for any errors. Of course it should go without saying that you need to backup all your databases first.

One other note, according to the MSDN library instructions for this parameter: If you use the SKUUPGRADE parameter, Setup will remove all hotfix and service pack updates from the SQL Server instance being upgraded. Once the edition upgrade is complete, you must re-apply all hotfix and service pack updates.

And last note, the command as written will upgrade the default local instance of SQL Server, if you are working with a remote instance or a named or otherwise non-default instance you will need to do some spelunking in the help files. A great place to start is here which is an MSDN article on How to install SQL Server 2005 from a command line.

Your mileage may vary but my own experience was uneventful and successful. I re-applied SP1 and then the post SP1 cumulative hotfixes and I was up and running! My previously installed Standard Edition now reports that it is indeed a Developer Edition install.

Final warning, if you are using Team Foundation server and the SQL Server you are about to work with is also used to host the Team Foundation Server schema changing it to Developer edition will break Team Foundation Server which will not run on the Developer Edition. Be sure before you change the edition of you server that you think through any other cross dependencies before you pull that trigger!

Cheers,

Robert Porter

 


 
Categories: SQL | Visual Studio


November 14, 2006
@ 06:01 PM

Now that Office 2007 has gone “Gold” and is available for download and soon on retail shelves, it would be a good time to go here and download the “Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint 2007 File Formats”.

According to Microsoft’s web site this does the following:

 By installing the Compatibility Pack in addition to Microsoft Office 2000, Office XP, or Office 2003, you will be able open, edit, and save files using the file formats new to Word, Excel, and PowerPoint 2007. The Compatibility Pack can also be used in conjunction with the Microsoft Office Word Viewer 2003, Excel Viewer 2003, and PowerPoint Viewer 2003 to view files saved in these new formats. For more information about the Compatibility Pack, see Knowledge Base article 923505.

Since Office 2007 has new formats for everything it is only a matter of time before someone sends you a Word or Excel file that you cannot open with your older version of Office. This option should mitigate the pain somewhat!

Cheers,

Robert Porter


 
Categories: Misc | Office


November 12, 2006
@ 02:07 PM

Over the years I have used a number of tools to read and keep track of my RSS subscriptions. Until very recently I was using FeedReader which is a free software application. I really liked it’s clean interface and overall capabilities. However it did not handle Podcasts and other enclosures very well. And lately, I noticed a number of feeds that it just could not display correctly.

Being free, I could not complain, however I did send several of the links that it had trouble with to Toomas Toots, the CEO and apparently also the programmer. Never did get a reply. Ah well, onwards…

Prior to FeedReader I had used SharpReader by Luke Hutteman, it too was a great, clean RSS reader, but it is showing it’s age now. It has not been updated since August, and most of the releases since July were bug fixes and minor tweaks. It also does not have any support for enclosures and was having a tough time with several feeds that I regularly read.

SharpReader was and remains donateware, so in a sense it is free but the author does ask for a donation and I imagine if a few more people would donate he might be motivated to continue development and add features. (I have not donated, and I should have, just wanted to make that clear.)

I have also used on and off Attensa and IntraVNews two readers that support direct integration with Outlook. I really do want to have my feeds integrated with Outlook, and yes I have tried the new integrated support built into Outlook 2007. But so far none of them are very compatible with the variety of feeds and formats out there.

Attensa and IntraVNews are both free, and both do a fairly good job of integrating into Outlook. But both suffer from the same problems of difficulty displaying feeds correctly, and they both had issues where I was trying to create a River of News format within Outlook, in Attensa this feature is supposedly built in, however I could not get it working in Outlook 2007.

I have also experimented with NewsGator and a number of other readers including the web based ones, Firefox’s reader, and a number of others.

Then, I found FeedDemon! I had looked at it before but had not wanted to pay $30.00 for an RSS reader when so many free choices are available. I also was clinging to the hope that I could get an integrated reader working in Outlook the way I wanted. FeedDemon is a Newsgator product, but it is standalone and mostly independent of the rest of their product line.

Aside from the fact that it does not integrate directly into Outlook, it has become my favorite RSS reader! It just works! And it handles Podcasts, integrates with either iTunes or Microsoft Media Player, supports playlists etc!!!!

I love it! I have moved all my subscriptions over to it and it runs when I start my system, I can’t say enough good things about the product. Everytime I think, “I wish it did XYZ”, I look and find the feature! For $29.95 you can’t go wrong! Every feed I have displays correctly  and crisply, it syncronizes my read/unread counts across my systems, it’s wonderful!

Highly recommended!!!

Cheers,

Robert Porter

 

 


 
Categories: Reviews | Tools and Toys


Ted Demopoulos has just published his second book. He co-authored “Blogging for Business” which is a great resource if you are interested in blogging.

Blogging_and_podcasting

His new book is a different approach entirely, but still must read material for anyone blogging or interested in blogging. The book is a series of 101 interviews with real world bloggers and podcasters. -disclaimer time, I was one of the 101 he interviewed in the book. However I was interviewed on how I use blogs, not on my blogging skills.

You may have heard of Robert Scoble, he was a breakthrough blogger at Microsoft, and introduced a degree of transparency at Microsoft through his blogging. Indeed Microsoft now has probably the largest stable of company bloggers of any company.

Ted interviewed Jeff Foster of Symantec about Microsoft’s use of blogs, and Foster offered the opinion that blogging by Microsoft employees had changed his opinion of Microsoft positively. That’s a striking observation in my book, and it shows what a powerful tool blogging can be.

One of the more colorful interviews in the book is with Andre The Splogger, whom Ted met in a bar in Khanty-Maniysk in Central Siberia. (Is there no limit to where Ted will go for an interview?) Andre is a self described “cab driver, reindeer breeder, and Internet entrepreneur” that happens to run a Spam Blog, or Splog.

There are also chapters on Monetising blogs and podcasts, (yes Virginia, you can make money by blogging!), and even chapters on Military blogging. He covers the entire spectrum of blogging and podcasting including areas I never would have known about. (Student Loan blogs anyone? How about Mommy Casts?)

I highly recommend this book to anyone interested in blogging or podcasting, or just generally interested in what all the fuss is about. The book does not require a technical degree to read, its written in a conversational style with lots of humor and clearly explained concepts. However, if you are technical, you will also bring away a great deal of information to help you evangalize and improve your own efforts.

And while you are at it, check out Ted’s own blog at Blogging for Business for even more resources and information.

Cheers,

Robert Porter


 
Categories: Books | Reviews


November 2, 2006
@ 06:04 PM

I downloaded and installed IE7 on the day it was released. And have been fairly pleased with it overall. I still tend to use Firefox as my default and main browser, but that may change.

One thing I have noticed of late, as soon as I get 4 – 6 tabs open in IE the CPU usage pegs, Memory use skyrockets and then the browser becomes non-responsive.

This was not the case following the initial installation, and I have added some toolbars, including the beta version of Yahoo’s new toolbar, so I suspect that the issue is a conflict.

If anyone knows of anything that could be causing this behavior please do let me know. And if I solve it I will post an update here.

Cheers,

Robert Porter


 
Categories: Browser | CSS | Reviews | Tools and Toys


Microsoft has made available many of the most frequently asked for Hotfixes. Now we can, finally, get them without having to go through a 30 minute minimum process of contacting Microsoft Product Support Services.

The site containing the released hotfixes is here its part of the Connect program at MS, and is called DevDiv Hotfix Public Availability Pilot Program.

Now, the majority of the words in the title of that bugger indicate that this is a perishable resource likely to go away at any time, so browse over there and download these bad boys before they go poof, even if you don’t install them. I suggest you also read the KB articles associated with each and store the contents with the downloaded files.

They have posted the standard “Own Risk” warning on the site, most if not all of these fixes have not been through their own internal testing. So do use with discretion!

Cheers,

Robert Porter


 
Categories: Programming | Rave | Visual Studio