<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Beth Massi - Sharing the goodness that is VB : SQL Server</title><link>http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx</link><description>Tags: SQL Server</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Building Occasionally Connected Smart Clients with WPF</title><link>http://blogs.msdn.com/bethmassi/archive/2009/11/02/building-occasionally-connected-smart-clients-with-wpf.aspx</link><pubDate>Mon, 02 Nov 2009 22:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9916434</guid><dc:creator>Beth Massi</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9916434.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9916434</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9916434</wfw:comment><description>&lt;p&gt;This month Dev Pro Connections has an article by Milind Lele on using Sync Services in a WPF application:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.devproconnections.com/tabId/180/itemId/4586/Building-Occasionally-Connected-Smart-Clients-with.aspx" target="_blank"&gt;Building Occasionally Connected Smart Clients with WPF&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;With Sync Services and Visual Studio 2008 you can visually design your local data cache and have it automatically synchronize your data with the backend remote database. So instead of figuring out your own caching mechanisms on the client, you can use SQL CE to store the local data and then use the sync framework to merge data with the backend.&lt;/p&gt;  &lt;p&gt;If you’re looking to improve scalability of your client applications then you should consider caching data that is read-only, user-specific, changes rarely, or can tolerate some staleness. ADO.NET Sync Services can really help here. &lt;/p&gt;  &lt;p&gt;You can catch more of Milind and team over on the VS Data Team Blog: &lt;a title="http://blogs.msdn.com/vsdata/" href="http://blogs.msdn.com/vsdata/"&gt;http://blogs.msdn.com/vsdata/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9916434" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>Inserting Master-Detail Data into a SQL-Server Compact Edition Database</title><link>http://blogs.msdn.com/bethmassi/archive/2009/09/15/inserting-master-detail-data-into-a-sql-server-compact-edition-database.aspx</link><pubDate>Wed, 16 Sep 2009 05:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9895646</guid><dc:creator>Beth Massi</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9895646.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9895646</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9895646</wfw:comment><description>&lt;P&gt;Yesterday John posted on the &lt;A href="http://blogs.msdn.com/vsdata/default.aspx" mce_href="http://blogs.msdn.com/vsdata/default.aspx"&gt;Visual Studio Data&lt;/A&gt; blog how to &lt;A href="http://blogs.msdn.com/vsdata/archive/2009/09/14/refresh-the-primary-key-identity-column-during-insert-operation.aspx" mce_href="http://blogs.msdn.com/vsdata/archive/2009/09/14/refresh-the-primary-key-identity-column-during-insert-operation.aspx"&gt;Refresh the Primary Key Identity Column during an Insert Operation&lt;/A&gt; using SQL Server. In that post he shows how the DataSet designer sets up a batch Insert statement to retrieve identity keys automatically. A while back &lt;A href="http://blogs.msdn.com/bethmassi/archive/2009/05/14/using-tableadapters-to-insert-related-data-into-an-ms-access-database.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2009/05/14/using-tableadapters-to-insert-related-data-into-an-ms-access-database.aspx"&gt;I wrote about how to insert data into an Access database using TableAdapters and identity keys&lt;/A&gt;. Because Access doesn’t support batch statements, the Visual Studio Dataset designer doesn’t generate the code to retrieve the identity on new rows, so you end up having to write a bit of code yourself to do this as I showed in that post. &lt;/P&gt;
&lt;P&gt;Since then I’ve had similar questions about how to do the same thing but using a SQL CE (Compact Edition) database so I thought I’d present the updated code to work with this type of database. Let’s take a look at how to do that, but first some background. (If you don’t care, just skip to the end for the code and &lt;A href="http://code.msdn.microsoft.com/InsertSQLCE/" target=_blank mce_href="http://code.msdn.microsoft.com/InsertSQLCE/"&gt;sample download&lt;/A&gt; ;-))&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What is SQL-Server Compact Edition (SQL CE)?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ms172448.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms172448.aspx"&gt;SQL CE&lt;/A&gt; is a file-based, single-user database that is really handy to use as local storage for your client applications because of its small footprint. And it’s included with Visual Studio 2008. &lt;A href="http://msdn.microsoft.com/en-us/library/ms172417.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms172417.aspx"&gt;Check out what’s new in SQL CE 3.5 here&lt;/A&gt;. One very typical use of SQL CE is as a local data cache to your SQL Server backend data using sync services in order to create an &lt;A href="http://msdn.microsoft.com/en-us/library/bb384572.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb384572.aspx"&gt;occasionally connected application&lt;/A&gt;. You can &lt;A href="http://msdn.microsoft.com/en-us/library/cc281959.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc281959.aspx"&gt;learn about the sync framework here&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/bb384585.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb384585.aspx"&gt;how to create a local data cache in Visual Studio 2008 here&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Setting up Parent-Child Tables and Relationships in SQL CE 3.5 Using Visual Studio 2008&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To add a local database file to your Visual Studio 2008 project just select Add –&amp;gt; New Item, choose the Data category and then select Local Database. This will add a SQL CE database file with an .sdf extension to your project.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_2.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb.png" width=681 height=410 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This will trigger the Data Sources wizard to start but first we need to create some tables in our database so cancel the wizard. Next open up the Server Explorer (or Database Explorer if you are using VS Express) and you should see your SQL CE database listed under Data Connections. Expand the database node and then right-click on Tables and select &lt;STRONG&gt;New Table&lt;/STRONG&gt;. A dialog will open that allows you to design your table schema. &lt;/P&gt;
&lt;P&gt;For this example I’ll create a parent Categories table and a child Products table with just a few fields to illustrate the concepts here. It’s important when you create a primary key that you choose the &lt;STRONG&gt;int&lt;/STRONG&gt; data type, set Unique to &lt;STRONG&gt;Yes&lt;/STRONG&gt; and then below in the column properties you set Identity to &lt;STRONG&gt;True&lt;/STRONG&gt;. This will create an auto-incrementing, unique primary key. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_6.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_6.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_2.png" width=681 height=556 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Click OK when you’re done and then repeat the same process to add a new Products table. This time though we need to specify a field for the CategoryID foreign key and I’m going to make this a required field by setting Allow Nulls to &lt;STRONG&gt;No&lt;/STRONG&gt;. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_8.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_8.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_3.png" width=679 height=551 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Now we need to add a relationship between these tables so that our little database will maintain referential integrity for us. We’re saying that a Product cannot exist without specifying a Category. We want the database to enforce this so that if we try to delete a Category it will prevent us from doing so if there are any Products. SQL CE 3.5 can maintain this kind of referential integrity for us, just go back to the Server Explorer and right-click on the Products table again but this time select &lt;STRONG&gt;Table Properties&lt;/STRONG&gt;. Select the &lt;STRONG&gt;Add Relations &lt;/STRONG&gt;page.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_10.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_10.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_4.png" width=713 height=581 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_4.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Type in the name of the relation you want to create and then select the Foreign Key Table Column, in my case I select CategoryID. Notice that you can also set up cascading or set null/default update and delete rules as well, but for this example we want to leave the rules as NO ACTION. Click Add Columns button then Add Relations button then click OK to save and close. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Setting up the Parent-Child DataSet &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Now that we have the database set up we can design our DataSet. This is going to be almost exactly the same as &lt;A href="http://blogs.msdn.com/bethmassi/archive/2009/05/14/using-tableadapters-to-insert-related-data-into-an-ms-access-database.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2009/05/14/using-tableadapters-to-insert-related-data-into-an-ms-access-database.aspx"&gt;how we set up our Access DataSet here&lt;/A&gt; so take a look at that post for the screen-shots, they’ll be the same here. To recap, you need to make sure you set up the relationship on the DataSet properly so that the primary key on the parent will cascade to the foreign key on the child. Right click on the relation in the DataSet designer and select "Both Relation and Foreign Key Constraint" and then set the Update and Delete rules to &lt;STRONG&gt;Cascade&lt;/STRONG&gt;. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_12.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_12.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 0px 20px 0px 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image align=left src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_5.png" width=228 height=341 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_5.png"&gt;&lt;/A&gt;The other important thing you need to do is set the Primary Key fields on both DataTables to ReadOnly &lt;STRONG&gt;False&lt;/STRONG&gt;. We need to do this so we can set them in code and have the DataRelation cascade rules work correctly.&lt;/P&gt;
&lt;P&gt;The DataSet designer will set all the rest of the properties and statements up correctly so you don’t have to modify anything else, though I do encourage you to take a look through them. One important thing to notice is the AutoIncrement, AutoIncrementSeed and AutoIncrementStep properties here. These are set to True, –1 and –1 respectively. This means that on the DataSet (client side) the referential integrity on new rows is maintained between the products and categories DataTables using temporary primary keys that are negative integers. &lt;STRONG&gt;These do NOT correspond to the keys in the database for new rows.&lt;/STRONG&gt; It’s not until we send the updates to the database that we get the real identity keys so keep that in mind. (And these properties are the same regardless if you are using SQL CE, Access, or SQL Server identity keys.)&lt;/P&gt;
&lt;P&gt;Okay so now we are ready to design our master-detail form. This should be a familiar process at this point but just in case here’s a recap. Open the Data Sources window (Main Menu –&amp;gt; Data –&amp;gt; Show Data Sources) and you should see the Categories and Products DataTables that are in the DataSet we just created. Design your Master-Detail form like normal. For this example I drag the Categories as details and then select the &lt;EM&gt;related &lt;/EM&gt;Products by expanding the Categories node and dragging the Products table under there. This will set up a relationship on the form as well so that when we select a Category, it will only show those related products. This is also important to get our inserts to work correctly because the temporary identity key (-1, –2, –3, etc) on the CategoryID will automatically cascade to the Product’s CategoryID. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_16.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_16.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_7.png" width=675 height=380 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_7.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Loading and Editing the Parent-Child DataSet&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Now that the DataSet is set to enforce the foreign key relationships, this means that you &lt;STRONG&gt;must&lt;/STRONG&gt; have a parent for every child so you have to load the data in parent then child order. Remember, you have to &lt;STRONG&gt;make sure that every row in the child DataTable will have a corresponding parent row in the parent DataTable&lt;/STRONG&gt;. This also means that you have to make sure to call EndEdit on any new parent BindingSource before any children can be added. I’m doing this by adding a handler to the grid’s Enter event. So the code-behind for this form is the same as the &lt;A href="http://code.msdn.microsoft.com/AccessDataVS/" target=_blank mce_href="http://code.msdn.microsoft.com/AccessDataVS/"&gt;Access sample I showed before&lt;/A&gt;:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Public Class &lt;/SPAN&gt;Form1

    &lt;SPAN style="COLOR: blue"&gt;Private Sub &lt;/SPAN&gt;CategoriesBindingNavigatorSaveItem_Click() _&lt;BR&gt;                &lt;SPAN style="COLOR: blue"&gt;Handles &lt;/SPAN&gt;CategoriesBindingNavigatorSaveItem.Click
        &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.Validate()
        &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.CategoriesBindingSource.EndEdit()
        &lt;SPAN style="COLOR: green"&gt;'Make sure to call EndEdit on all BindingSources before an update
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.ProductsBindingSource.EndEdit()
        &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.TableAdapterManager.UpdateAll(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.MyDatabaseDataSet)
    &lt;SPAN style="COLOR: blue"&gt;End Sub

    Private Sub &lt;/SPAN&gt;Form1_Load() &lt;SPAN style="COLOR: blue"&gt;Handles MyBase&lt;/SPAN&gt;.Load
        &lt;SPAN style="COLOR: green"&gt;'Load parent before child because contraints are enabled on the DataSet
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.CategoriesTableAdapter.Fill(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.MyDatabaseDataSet.Categories)
        &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.ProductsTableAdapter.Fill(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.MyDatabaseDataSet.Products)
    &lt;SPAN style="COLOR: blue"&gt;End Sub
   
    Private Sub &lt;/SPAN&gt;ProductsDataGridView_Enter() &lt;SPAN style="COLOR: blue"&gt;Handles &lt;/SPAN&gt;ProductsDataGridView.Enter
        &lt;SPAN style="COLOR: green"&gt;'You must commit the parent row to the DataTable before adding child rows 
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.CategoriesBindingSource.EndEdit()
    &lt;SPAN style="COLOR: blue"&gt;End Sub
End Class&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;&lt;STRONG&gt;Adding Code to Handle Inserts to SQL CE Databases&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;We need a way to set the primary key on the parent right after the row is inserted into the database and before any children are inserted. Now that we have keys cascading we just need to write code to handle the RowUpdated event on the DataAdapter inside the TableAdapter partial class. TableAdapters are generated classes that Visual Studio creates for us from the DataSet designer. These classes are declared as &lt;A href="http://msdn.microsoft.com/en-us/library/yfzd5350.aspx" mce_href="http://msdn.microsoft.com/en-us/library/yfzd5350.aspx"&gt;Partial Classes&lt;/A&gt; so that means we can add code to the same class even if it’s in a separate file. Right-click on the TableAdapter class in the DataSet Designer and select View Code and the partial class file that you can edit will be created for you.&lt;/P&gt;
&lt;P&gt;Now we can write code to automatically query the database for the identity key because SQL CE supports the @@IDENTITY command just like Access. We need to execute this query after each &lt;STRONG&gt;new &lt;/STRONG&gt;row has been inserted into the database, but before any children. If you’re using Visual Studio 2008 then the TableAdapterManager will handle sending parents first then children for insert operations so all we need to do is handle the DataAdapter’s RowUpdated event. Here’s the complete code listing for the DataSet and TableAdapter partial classes which includes code to set default values on the new rows. Notice it’s very similar to the Access code.&amp;nbsp; We’re just working with a different data access client library by importing the System.Data.SqlServerCe instead of System.Data.OleDb.&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Imports &lt;/SPAN&gt;System.Data.SqlServerCe

&lt;SPAN style="COLOR: blue"&gt;Public Class &lt;/SPAN&gt;SQLCEIDHelper
    &lt;SPAN style="COLOR: green"&gt;''' &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;''' Retrieves the primary key auto-number identity values from SQL CE
    ''' &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;''' &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public Shared Sub &lt;/SPAN&gt;SetPrimaryKey(&lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;trans &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;SqlCeTransaction, _
                                    &lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;e &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;SqlCeRowUpdatedEventArgs)

        &lt;SPAN style="COLOR: green"&gt;' If this is an INSERT operation...
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If &lt;/SPAN&gt;e.Status = UpdateStatus.Continue &lt;SPAN style="COLOR: blue"&gt;AndAlso &lt;/SPAN&gt;_
           e.StatementType = StatementType.Insert &lt;SPAN style="COLOR: blue"&gt;Then
            Dim &lt;/SPAN&gt;pk = e.Row.Table.PrimaryKey
            &lt;SPAN style="COLOR: green"&gt;' and a primary key PK column exists...
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If &lt;/SPAN&gt;pk &lt;SPAN style="COLOR: blue"&gt;IsNot Nothing AndAlso &lt;/SPAN&gt;pk.Count = 1 &lt;SPAN style="COLOR: blue"&gt;Then
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;'Set up the post-update query to fetch new @@Identity
                &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;cmdGetIdentity &lt;SPAN style="COLOR: blue"&gt;As New &lt;/SPAN&gt;SqlCeCommand(&lt;SPAN style="COLOR: #a31515"&gt;"SELECT @@IDENTITY"&lt;/SPAN&gt;, _
                                                       &lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(trans.Connection, SqlCeConnection), _
                                                       trans)
                
                &lt;SPAN style="COLOR: green"&gt;'Execute the command and set the result identity value to the PK
                &lt;/SPAN&gt;e.Row(pk(0)) = &lt;SPAN style="COLOR: blue"&gt;CInt&lt;/SPAN&gt;(cmdGetIdentity.ExecuteScalar)
                e.Row.AcceptChanges()

            &lt;SPAN style="COLOR: blue"&gt;End If
        End If
    End Sub
End Class

Namespace &lt;/SPAN&gt;MyDatabaseDataSetTableAdapters
    &lt;SPAN style="COLOR: blue"&gt;Partial Public Class &lt;/SPAN&gt;CategoriesTableAdapter
        &lt;SPAN style="COLOR: blue"&gt;Private Sub &lt;/SPAN&gt;_adapter_RowUpdated(&lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;sender &lt;SPAN style="COLOR: blue"&gt;As Object&lt;/SPAN&gt;, _
                                        &lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;e &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;SqlCeRowUpdatedEventArgs) _
                                        &lt;SPAN style="COLOR: blue"&gt;Handles &lt;/SPAN&gt;_adapter.RowUpdated

            SQLCEIDHelper.SetPrimaryKey(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.Transaction, e)
        &lt;SPAN style="COLOR: blue"&gt;End Sub
    End Class

    Partial Public Class &lt;/SPAN&gt;ProductsTableAdapter
        &lt;SPAN style="COLOR: blue"&gt;Private Sub &lt;/SPAN&gt;_adapter_RowUpdated(&lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;sender &lt;SPAN style="COLOR: blue"&gt;As Object&lt;/SPAN&gt;, _
                                        &lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;e &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;SqlCeRowUpdatedEventArgs) _
                                        &lt;SPAN style="COLOR: blue"&gt;Handles &lt;/SPAN&gt;_adapter.RowUpdated

            SQLCEIDHelper.SetPrimaryKey(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.Transaction, e)
        &lt;SPAN style="COLOR: blue"&gt;End Sub
    End Class
End Namespace

Partial Class &lt;/SPAN&gt;MyDatabaseDataSet
    &lt;SPAN style="COLOR: blue"&gt;Partial Class &lt;/SPAN&gt;CategoriesDataTable
        &lt;SPAN style="COLOR: blue"&gt;Private Sub &lt;/SPAN&gt;CategoriesDataTable_TableNewRow(&lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;sender &lt;SPAN style="COLOR: blue"&gt;As Object&lt;/SPAN&gt;, _
                                            &lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;e &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;System.Data.DataTableNewRowEventArgs) _
                                            &lt;SPAN style="COLOR: blue"&gt;Handles Me&lt;/SPAN&gt;.TableNewRow
            &lt;SPAN style="COLOR: green"&gt;'Set defaults so that constraints don't fail when EndEdit is called
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;cat = &lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(e.Row, CategoriesRow)
            cat.CategoryName = &lt;SPAN style="COLOR: #a31515"&gt;"[new]"
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End Sub
    End Class

    Partial Class &lt;/SPAN&gt;ProductsDataTable
        &lt;SPAN style="COLOR: blue"&gt;Private Sub &lt;/SPAN&gt;ProductsDataTable_TableNewRow(&lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;sender &lt;SPAN style="COLOR: blue"&gt;As Object&lt;/SPAN&gt;, _
                                             &lt;SPAN style="COLOR: blue"&gt;ByVal &lt;/SPAN&gt;e &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;System.Data.DataTableNewRowEventArgs) _
                                             &lt;SPAN style="COLOR: blue"&gt;Handles Me&lt;/SPAN&gt;.TableNewRow
            &lt;SPAN style="COLOR: green"&gt;'Set defaults so that constraints don't fail when EndEdit is called
            &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim &lt;/SPAN&gt;product = &lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(e.Row, ProductsRow)
            product.ProductName = &lt;SPAN style="COLOR: #a31515"&gt;"[new]"
        &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End Sub
    End Class
End Class&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;Now when we run our form, click the Add button on the ToolStrip to add a new Category and then enter new Products in the DataGridView below. Click Save and you will see the identity keys refresh back into the DataTables from our SQL CE database. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_18.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_18.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_8.png" width=580 height=333 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/InsertingMasterDetailDataintoaSQLServerC_C610/image_thumb_8.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;So to recap:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create your SQL CE tables, set the PKs to an Identity Integer column and then set up the relation to enforce referential integrity&lt;/LI&gt;
&lt;LI&gt;Create your DataSet and edit the relation and set it to a “Relation and Foreign Key Constraint” then set the Update and Delete rules to Cascade&lt;/LI&gt;
&lt;LI&gt;Make sure the PKs on the DataTables in the designer are set ReadOnly False&lt;/LI&gt;
&lt;LI&gt;Make sure to design your form so that the parent and &lt;EM&gt;related &lt;/EM&gt;children BindingSources are set up properly&lt;/LI&gt;
&lt;LI&gt;Call EndEdit on the ParentBindingSource before you attempt to insert any child rows into the child DataTable so that the parent row is committed to the parent DataTable&lt;/LI&gt;
&lt;LI&gt;Use the TableAdapterManager to handle updating parents and children in proper order (this happens by default if you use the designer)&lt;/LI&gt;
&lt;LI&gt;Add a handler to the DataAdapter’s RowUpdated event to query the database for the new identity (SELECT @@IDENTITY) and set the PK on the DataRow to that value and this will cascade to any related children automatically&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;A href="http://code.msdn.microsoft.com/InsertSQLCE/" target=_blank mce_href="http://code.msdn.microsoft.com/InsertSQLCE/"&gt;&lt;STRONG&gt;Download the sample application from Code Gallery.&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I hope that clears up the confusion on how to work with file-based databases like Access and SQL CE that don’t support batch statements. Once you understand how ADO.NET is working with your DataSets then it’s much easier to understand how to configure things like this. SQL CE is a great FREE database for single-user applications and I encourage you to have a look at it if you’re building these types of client applications. &lt;/P&gt;
&lt;P&gt;SQL CE also supports the Entity Framework so that would probably be a good follow-up post to this one… next time! ;-)&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9895646" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>“Moving in” to Windows 7: My Favorite Features &amp; Some Tips on Setup</title><link>http://blogs.msdn.com/bethmassi/archive/2009/09/01/moving-in-to-windows-7-my-favorite-features-some-tips-on-setup.aspx</link><pubDate>Wed, 02 Sep 2009 03:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9890150</guid><dc:creator>Beth Massi</dc:creator><slash:comments>13</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9890150.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9890150</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9890150</wfw:comment><description>&lt;P&gt;Last week I installed Windows 7 Enterprise on my main laptop – a Lenovo T60p ThinkPad. I was up in Redmond and MSIT made it available via a super-easy network boot that installs Office Enterprise, all the IT-required software like anti-virus, and all the drivers you need automatically. (I can’t say enough great things about MSIT but that’s another post.) It took about an hour and a half and I was cooking with gas. &lt;/P&gt;
&lt;P&gt;Like moving into a new apartment, moving into a new operating system can take a little time to see the awesomeness as well as understand the quirks. Now that I’ve been doing my “normal work routine” on it for a week I thought I’d post some of my favorite features of this OS as well as share some tips when I was setting up my system and installing programs like Visual Studio and SQL Server 2008.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;3 Favorite Windows 7 Features&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My #1 favorite feature&lt;/STRONG&gt;, hands down, is being able to boot from a VHD. You can create Windows 7 or Windows 2008 RC Server images via Hyper-V, run sysprep on them, and then copy them to your hard drive. Then you use bcdedit to put an entry in your boot menu and Windows will happily boot right into it like normal. You can even access all your files from the image just like it was another partition. Plus, since my laptop supports 64-bit I can create 32 and 64-bit images and boot from any of them. Now when I am testing or demoing Visual Studio 2010 &amp;amp; Office/SharePoint 2010 it will be almost as fast as if I installed on the metal. Yippie! (I say almost, but I only noticed a bit of sluggishness on startup.)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/aviraj/archive/2009/01/18/windows-7-boot-from-vhd-first-impression-part-2.aspx" target=_blank mce_href="http://blogs.technet.com/aviraj/archive/2009/01/18/windows-7-boot-from-vhd-first-impression-part-2.aspx"&gt;Here’s the instructions I used to set it up.&lt;/A&gt; Many thanks to &lt;A href="http://blogs.technet.com/aviraj" target=_blank mce_href="http://blogs.technet.com/aviraj"&gt;Aviraj&lt;/A&gt; for this information and thanks to my co-worker Sam for pointing me to it :-)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My #2 favorite feature &lt;/STRONG&gt;is the window docking. Scott Hanselman showed me this at Denver code camp in the beginning of the year. Take any window and drag it near the left or right of your screen and it will dock there, filling up exactly half the screen. This is super helpful if you don’t have two monitors (like on a laptop) but need to see the contents of two windows at once. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_2.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb.png" width=683 height=427 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;If you drag the window to the top of the screen it will automatically maximize. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My #3 favorite feature &lt;/STRONG&gt;is that the Taskbar buttons combine and preview, especially for IE browser windows, but it works for any application. In the picture below (click to enlarge) my mouse is hovering over the IE icon on the taskbar and Windows 7 automatically previews all the open windows &lt;STRONG&gt;and tabs. &lt;/STRONG&gt;Here I have three browser windows open and 11 tabs total:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_6.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_6.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb_2.png" width=684 height=77 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb_2.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Clicking the taskbar icon also does the same thing if there are multiple previews. When you hover over the previews, the full size window will come into view. It’s a really nice feature when you have a lot of windows open for a particular program. However, especially with IE, sometimes you just want to open any of them so you can navigate somewhere else. If you Ctrl+click then it will open the last window you accessed. If you Shift+click then it will open a new instance of the program. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Taskbar Tips&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In the pictures above you may have noticed I have a “&lt;STRONG&gt;Quick Launch Bar&lt;/STRONG&gt;” (at least that’s what it was called in Vista) next to the Start menu. In Windows 7 there’s no such thing so you have to create it yourself. Right-click the Taskbar, select Toolbars, New Toolbar… and that will open a dialog that wants you to select a folder. That seemed a bit odd to me but I played along and selected somewhere in my Documents library. Name the folder whatever you want, like MyToolbar. Now there’s some text on your Taskbar called MyToolbar next to your system tray. Clicking on it does nothing. Hmmm. &lt;/P&gt;
&lt;P&gt;Well it turns out what you need to do is go back into that folder you created and start adding shortcuts! Right-click on MyToolbar, select Open Folder, and then you can start right-dragging and creating shortcuts to all your favorite programs. Now you will see a little double left arrow next to MyToolbar and clicking it will show all your shortcuts: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_10.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_10.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb_4.png" width=247 height=213 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb_4.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In order to get the toolbar to look like the old Quick Launch you need to right-click on the Taskbar and uncheck “Lock the Taskbar”. Then you can right-click on MyToolbar and uncheck “Show Text” and “Show Title”: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_12.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_12.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 0px 10px 0px 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb_5.png" width=248 height=241 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb_5.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Now since the Taskbar is unlocked you can stretch out the toolbar and move it to where you want. If you want it on the left then slide it all the way past the Taskbar icons then slide the Taskbar icons back to where you want them. When you’re done, lock the Taskbar again and you should be a happy camper. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;“Show Desktop” on the Left&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;One thing that annoys me about the Taskbar is that you can’t move the Show Desktop which is now at the end of the Taskbar on the right (the black box). I’ve tried for a week to train myself to go to the right instead of the left (like where it was in XP and Vista) but it’s been too many years of my brain on those OSes so I can’t break the habit. &lt;/P&gt;
&lt;P&gt;If you’re like me and want the Show Desktop on the left next to the Start menu then create a toolbar like I showed above. Next, open up Notepad and write the following Explorer commands:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;[Shell] &lt;BR&gt;Command=2 &lt;BR&gt;IconFile=explorer.exe,3 &lt;BR&gt;[Taskbar] &lt;BR&gt;Command=ToggleDesktop&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Then save the file in the the toolbar folder you created and name it “Show Desktop.scf” (use the quotes in Notepad’s Save dialog so that it doesn’t append the txt extension). Now you can move it on your toolbar all the way to the left and all will be right with the world (or at least your Taskbar):&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_14.png" target=_blank mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_14.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb_6.png" width=213 height=59 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MyFavoriteWindows7FeaturesSoFar_C3AA/image_thumb_6.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Tips on Installing Visual Studio and SQL Server 2008&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;There is a known compatibility issue with SQL Server 2008 and Windows 7 that is fixed with &lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=66AB3DBB-BF3E-4F46-9559-CCC6A4F9DC19&amp;amp;displaylang=en"&gt;Service Pack 1&lt;/A&gt;. So if you are installing SQL Server 2008 (any version including Express) then you’ll get a compatibility warning. You can just click past it but then make sure you install Service Pack 1 right away (also available via Windows Update). &lt;A href="http://blogs.msdn.com/petersad/archive/2009/08/11/sql-server-on-windows-7.aspx" target=_blank mce_href="http://blogs.msdn.com/petersad/archive/2009/08/11/sql-server-on-windows-7.aspx"&gt;See this post for details on SQL Server Setup on Windows 7&lt;/A&gt;. You’ll also want to do the same thing for Visual Studio 2008, install &lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;amp;displaylang=en" target=_blank mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=FBEE1648-7106-44A7-9649-6D9F6D58056E&amp;amp;displaylang=en"&gt;Service Pack 1&lt;/A&gt;. You’ll need to do this because if SQL Server SP1 is installed then Visual Studio will need to also have SP1 installed. Finally, make sure you head to Windows Update to get any other latest fixes. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The Windows API Code Pack &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To wrap up this Windows 7 post, I’ll leave you with a link to the &lt;A href="http://code.msdn.microsoft.com/WindowsAPICodePack" target=_blank mce_href="http://code.msdn.microsoft.com/WindowsAPICodePack"&gt;Windows API Code Pack&lt;/A&gt; that’s been featured on the &lt;A href="http://msdn.com/vbasic" target=_blank mce_href="http://msdn.com/vbasic"&gt;Visual Basic Developer Center&lt;/A&gt; for a few weeks now. This pack provides a source code library that can be used to access Windows features from managed code and includes 20+ samples in Visual Basic and C#. &lt;A href="http://www.hanselman.com/blog/TheWeeklySourceCode45KickingButtOnWindows7AndWindowsXP.aspx" target=_blank mce_href="http://www.hanselman.com/blog/TheWeeklySourceCode45KickingButtOnWindows7AndWindowsXP.aspx"&gt;Scott Hanselman digs into it this week&lt;/A&gt;. It looks like a pretty easy way to take advantage of Windows 7 features in your .NET applications. &lt;/P&gt;
&lt;P mce_keep="true"&gt;Enjoy Windows 7!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9890150" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>Attaching a Local SQL Server Database Using sqlcmd</title><link>http://blogs.msdn.com/bethmassi/archive/2008/12/18/attaching-a-local-sql-express-database-using-sqlcmd.aspx</link><pubDate>Fri, 19 Dec 2008 01:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9238308</guid><dc:creator>Beth Massi</dc:creator><slash:comments>26</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9238308.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9238308</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9238308</wfw:comment><description>&lt;P&gt;I've been getting asked a lot lately about how to easily attach a local SQL Server/Express database file (.MDF file) to an instance of SQL Server&lt;STRONG&gt; (any edition)&lt;/STRONG&gt;. In most of my samples I distribute&amp;nbsp;&lt;A href="http://blogs.msdn.com/bethmassi/archive/2007/05/29/working-with-a-local-data-file-in-vs.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2007/05/29/working-with-a-local-data-file-in-vs.aspx"&gt;local SQL&amp;nbsp;Server databases&lt;/A&gt; and use user instance connection strings so that if you are running Visual Studio with SQL Express then hitting F5 will auto-attach SQL Express to the database when it runs. This will automatically create the log file (.LDF) as well for you. This "just works" approach works well for people who are using the default install of Visual Studio which installs a SQL Express instance. &lt;/P&gt;
&lt;P&gt;However, many developers (including myself) have SQL Server developer edition or higher already installed on our machines or connect to remote development machines with higher editions on them. We&amp;nbsp;want to attach the database file to our instance of SQL Server (by the way you can also&amp;nbsp;attach databases to&amp;nbsp;SQL Express). You can do this easily with &lt;A href="http://msdn.microsoft.com/en-us/library/ms165673.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms165673.aspx"&gt;sqlcmd as outlined in the MSDN library&lt;/A&gt;. Here are the steps:&lt;/P&gt;
&lt;P&gt;1. First copy the local database MDF file to the same location as your other databases. This is usually the folder: &lt;EM&gt;C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data (&lt;/EM&gt;or if you are using SQL Express it's probably &lt;EM&gt;C:\Program Files\Microsoft SQL Server\MSSQL.SQLEXPRESS\MSSQL\Data )&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;2. Next open a command prompt and connect to your server using sqlcmd using the syntax -S &lt;EM&gt;ServerName\&lt;/EM&gt;&lt;EM&gt;InstanceName. &lt;/EM&gt;You can use the .\ (dot-backslash) syntax to indicate the local server default instance. In the case of SQL Express the instance is called sqlexpress. So to connect to a local SQL Express database:&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face="Courier New"&gt;C:\&amp;gt;sqlcmd -S .\SQLEXPRESS&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Or if we were connecting to our local SQL Server&amp;nbsp;default instance:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;C:\&amp;gt;sqlcmd -S .\ &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Or&amp;nbsp;a named instance (SQLInstance) on another machine (RemoeMachine) it would be:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;FONT face="Courier New"&gt;C:\&amp;gt;sqlcmd -S RemoteMachine\SQLInstance &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;3. Next you need to switch to the master database (&amp;lt;enter&amp;gt; after each line below):&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face="Courier New"&gt;1&amp;gt; USE Master &lt;BR&gt;2&amp;gt; GO&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;4. Then you need to enter the following command to indicate the new database name to create and the location of the MDF file. This will attach the database and automatically create a new log file for you (&amp;lt;enter&amp;gt; after each line below):&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;1&amp;gt; CREATE DATABASE &lt;EM&gt;databaseName &lt;/EM&gt;ON &lt;BR&gt;2&amp;gt; (FILENAME= N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\&lt;EM&gt;MDFFileName&lt;/EM&gt;.MDF') &lt;BR&gt;3&amp;gt; FOR ATTACH; &lt;BR&gt;4&amp;gt; GO&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Where &lt;EM&gt;databaseName &lt;/EM&gt;is the name of the database and &lt;EM&gt;MDFFileName&lt;/EM&gt; is the physical name of the MDF file. Notice that we're omitting the log file location so it will create one automatically for you. Now you can change your connection strings in your applications to use this attached database in the &lt;A href="http://msdn.microsoft.com/en-us/library/25zf0ze8.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/25zf0ze8.aspx"&gt;application settings&lt;/A&gt;. For instance many of my samples use a local database called "OMS.MDF". Instead of the user instance connection string:&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face="Courier New"&gt;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\OMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;You can change the connection string in all those samples to:&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face="Courier New"&gt;Data Source=.\SQLEXPRESS;Initial Catalog=OMS;Integrated Security=True&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;It also becomes a lot easier to modify an attached database from the Visual Studio server explorer or from SQL Server Management Studio. Hope that clears it up for folks.&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9238308" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>Editing Data from Two Tables in a Single DataGridView</title><link>http://blogs.msdn.com/bethmassi/archive/2008/10/15/editing-data-from-two-tables-in-a-single-datagridview.aspx</link><pubDate>Thu, 16 Oct 2008 04:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9001289</guid><dc:creator>Beth Massi</dc:creator><slash:comments>24</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/9001289.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=9001289</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=9001289</wfw:comment><description>&lt;P&gt;I've had a lot of questions lately on how to display data from two separate tables in the database into a single DataGridView for editing. It sure would be nice if all our data was in a single table, but in reality most of the time it's not. Basically the problem is that we want one single table (entity) representation on the client even though we have two physical tables in the database holding the information... thus we need to "split" the data in our entity on the client side into two or more physical tables on the server. There are many ways you can do this depending on the relations in the database and also depending on what your client-side data source happens to be. I'll present a simple, common database table scenario and then attempt to explain how we can work with it using DataTables, LINQ to SQL classes, and then an Entity Data Model --- three different approaches to working with data in Visual Studio.&lt;/P&gt;
&lt;P&gt;So let's take a very simple example. In my database I have two tables with a one-to-one relationship, Customer and CustomerContactInfo, one storing basic information about a customer and another that stores contact information:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity1_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity1_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=244 alt=entity1 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity1_thumb.jpg" width=522 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity1_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Entity Splitting DataTables&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If we're using DataSets in our application already we probably want to represent this as a single Customer client-side DataTable. To do this, we need to specify some stored procedures in our database for Select, Insert, Update, and Delete so that when ADO.NET retrieves our data or sends back the updated, inserted and deleted rows to the database, it calls our stored procedures that do the work of splitting the data into the proper physical tables. You can easily map DataTables in the DataSet designer to stored procedures. In our example these stored procedures are going to be very simple:&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;CREATE PROCEDURE &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[GetCustomers] &lt;SPAN style="COLOR: blue"&gt;AS
SELECT  &lt;/SPAN&gt;cust&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;CustomerID&lt;SPAN style="COLOR: gray"&gt;, 
        &lt;/SPAN&gt;cust&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;Title&lt;SPAN style="COLOR: gray"&gt;, 
        &lt;/SPAN&gt;cust&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;FirstName&lt;SPAN style="COLOR: gray"&gt;, 
        &lt;/SPAN&gt;cust&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;MiddleName&lt;SPAN style="COLOR: gray"&gt;, 
        &lt;/SPAN&gt;cust&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;LastName&lt;SPAN style="COLOR: gray"&gt;, 
        &lt;/SPAN&gt;cust&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;Suffix&lt;SPAN style="COLOR: gray"&gt;, 
        &lt;/SPAN&gt;cust&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;CompanyName&lt;SPAN style="COLOR: gray"&gt;, 
        &lt;/SPAN&gt;cust&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;SalesPerson&lt;SPAN style="COLOR: gray"&gt;, 
        &lt;/SPAN&gt;contact&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;EmailAddress&lt;SPAN style="COLOR: gray"&gt;, 
        &lt;/SPAN&gt;contact&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;Phone
&lt;SPAN style="COLOR: blue"&gt;FROM    &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[Customer] &lt;SPAN style="COLOR: blue"&gt;AS &lt;/SPAN&gt;cust
&lt;SPAN style="COLOR: gray"&gt;JOIN    &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[CustomerContactInfo] 
        &lt;SPAN style="COLOR: blue"&gt;AS &lt;/SPAN&gt;contact &lt;SPAN style="COLOR: blue"&gt;ON &lt;/SPAN&gt;cust&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;CustomerID &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;contact&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;CustomerID&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;CREATE PROCEDURE &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[DeleteCustomer]&lt;SPAN style="COLOR: gray"&gt;(
    &lt;/SPAN&gt;@CustomerID [int]
&lt;SPAN style="COLOR: gray"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;AS
BEGIN

    DELETE   &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[CustomerContactInfo]
    &lt;SPAN style="COLOR: blue"&gt;WHERE    &lt;/SPAN&gt;[CustomerID] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@CustomerID
    
    &lt;SPAN style="COLOR: blue"&gt;DELETE   &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[Customer]
    &lt;SPAN style="COLOR: blue"&gt;WHERE    &lt;/SPAN&gt;[CustomerID] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@CustomerID
    
&lt;SPAN style="COLOR: blue"&gt;END&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;CREATE PROCEDURE &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[UpdateCustomer]&lt;SPAN style="COLOR: gray"&gt;(
    &lt;/SPAN&gt;@CustomerID [int]&lt;SPAN style="COLOR: gray"&gt;,
    &lt;/SPAN&gt;@Title [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;8&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@FirstName [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;50&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@MiddleName [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;50&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@LastName [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;50&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@Suffix [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;10&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@CompanyName [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;128&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@SalesPerson [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;256&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@EmailAddress [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;50&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@Phone [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;25&lt;SPAN style="COLOR: gray"&gt;)
) &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;AS
BEGIN

    UPDATE  &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[Customer]
    &lt;SPAN style="COLOR: blue"&gt;SET     &lt;/SPAN&gt;[Title] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@Title&lt;SPAN style="COLOR: gray"&gt;,
            &lt;/SPAN&gt;[FirstName] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@FirstName&lt;SPAN style="COLOR: gray"&gt;,
            &lt;/SPAN&gt;[MiddleName] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@MiddleName&lt;SPAN style="COLOR: gray"&gt;,
            &lt;/SPAN&gt;[LastName] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@LastName&lt;SPAN style="COLOR: gray"&gt;,
            &lt;/SPAN&gt;[Suffix] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@Suffix&lt;SPAN style="COLOR: gray"&gt;,
            &lt;/SPAN&gt;[CompanyName] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@CompanyName&lt;SPAN style="COLOR: gray"&gt;,
            &lt;/SPAN&gt;[SalesPerson] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@SalesPerson
    &lt;SPAN style="COLOR: blue"&gt;WHERE   &lt;/SPAN&gt;[CustomerID] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@CustomerID

    &lt;SPAN style="COLOR: blue"&gt;UPDATE  &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[CustomerContactInfo]
    &lt;SPAN style="COLOR: blue"&gt;SET     &lt;/SPAN&gt;[EmailAddress] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@EmailAddress&lt;SPAN style="COLOR: gray"&gt;,
            &lt;/SPAN&gt;[Phone] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@Phone
    &lt;SPAN style="COLOR: blue"&gt;WHERE   &lt;/SPAN&gt;[CustomerID] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;@CustomerID
    
&lt;SPAN style="COLOR: blue"&gt;END&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;CREATE PROCEDURE &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[InsertCustomer]&lt;SPAN style="COLOR: gray"&gt;(
    &lt;/SPAN&gt;@Title [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;8&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@FirstName [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;50&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@MiddleName [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;50&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@LastName [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;50&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@Suffix [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;10&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@CompanyName [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;128&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@SalesPerson [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;256&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@EmailAddress [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;50&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@Phone [nvarchar]&lt;SPAN style="COLOR: gray"&gt;(&lt;/SPAN&gt;25&lt;SPAN style="COLOR: gray"&gt;),
    &lt;/SPAN&gt;@CustomerID &lt;SPAN style="COLOR: blue"&gt;int OUTPUT
&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;) &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;AS
BEGIN

    INSERT INTO &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[Customer]
    &lt;SPAN style="COLOR: blue"&gt;VALUES &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(
        &lt;/SPAN&gt;@Title&lt;SPAN style="COLOR: gray"&gt;,
        &lt;/SPAN&gt;@FirstName&lt;SPAN style="COLOR: gray"&gt;,
        &lt;/SPAN&gt;@MiddleName&lt;SPAN style="COLOR: gray"&gt;,
        &lt;/SPAN&gt;@LastName&lt;SPAN style="COLOR: gray"&gt;,
        &lt;/SPAN&gt;@Suffix&lt;SPAN style="COLOR: gray"&gt;,
        &lt;/SPAN&gt;@CompanyName&lt;SPAN style="COLOR: gray"&gt;,
        &lt;/SPAN&gt;@SalesPerson &lt;SPAN style="COLOR: gray"&gt;)
    
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;-- Get back the customer ID 
    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;SELECT &lt;/SPAN&gt;@customerID &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;CustomerID
    &lt;SPAN style="COLOR: blue"&gt;FROM &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[Customer]
    &lt;SPAN style="COLOR: blue"&gt;WHERE &lt;/SPAN&gt;&lt;SPAN style="COLOR: magenta"&gt;@@ROWCOUNT &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;&amp;gt; &lt;/SPAN&gt;0 &lt;SPAN style="COLOR: gray"&gt;AND &lt;/SPAN&gt;[CustomerID] &lt;SPAN style="COLOR: gray"&gt;= &lt;/SPAN&gt;&lt;SPAN style="COLOR: magenta"&gt;scope_identity&lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;()

    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;INSERT INTO &lt;/SPAN&gt;[dbo]&lt;SPAN style="COLOR: gray"&gt;.&lt;/SPAN&gt;[CustomerContactInfo]
    &lt;SPAN style="COLOR: blue"&gt;VALUES &lt;/SPAN&gt;&lt;SPAN style="COLOR: gray"&gt;(
        &lt;/SPAN&gt;@customerID&lt;SPAN style="COLOR: gray"&gt;,
        &lt;/SPAN&gt;@EmailAddress&lt;SPAN style="COLOR: gray"&gt;,
        &lt;/SPAN&gt;@Phone&lt;SPAN style="COLOR: gray"&gt;)
    
&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;END&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;Now that we have that set up, open up the Data Source Window in Visual Studio and add a new data source, select the Database and then select just the GetCustomers stored procedure:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity2_4.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity2_4.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=480 alt=entity2 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity2_thumb_1.jpg" width=625 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity2_thumb_1.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Click Finish and then open up the DataSet designer by double-clicking on the CustomerDataset.xsd in the Solution Explorer. You'll notice that the name of the DataTable is GetCustomers so change that to just "Customer". Next we need to configure the DataTable so that it will use our stored procedures so right click on the DataTable and select "Configure...". The TableAdapter Configuration Wizard should open and this will allow you to map your stored procedures to the Update, Insert and Delete commands. By default the fields will match up by name so you shouldn't have to do anything but drop down the combo boxes and select the right procedures for each action.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity3_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity3_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=480 alt=entity3 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity3_thumb.jpg" width=624 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity3_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;To test this out you can drag the Customer table from the Data Sources window on to a Windows Form as a DataGrid and immediately run it. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity4_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity4_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=378 alt=entity4 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity4_thumb.jpg" width=640 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity4_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;You will see the data from both tables displayed in the grid and they will be editable. As you update, insert and delete rows here, the DataSet will keep track of these changes for you. So when it is time to save the data via a call to the TableAdapterManager.UpdateAll method, the proper stored procedure will be called for each row that was modified. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity5_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity5_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=189 alt=entity5 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity5_thumb.jpg" width=640 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity5_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Entity Splitting LINQ to SQL Classes&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;So with a Dataset, the DataTables do not have to map one-to-one with your database tables, but you need to specify how the data should be saved back to the database via stored procedures. This is also true if using LINQ to SQL classes. In that case though, you drag methods onto the method pane &lt;STRONG&gt;first&lt;/STRONG&gt; and then map them to the class in the designer by right-clicking on the class and selecting "Configure Behavior...". &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity6_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity6_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=480 alt=entity6 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity6_thumb.jpg" width=639 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity6_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;However with LINQ to SQL classes you can't map the Select behavior unfortunately. What you do instead is map the result of the GetCustomers method to a result type of Customer (the class we created on the design surface). &lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity7_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity7_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN: 5px 10px 0px 0px; BORDER-RIGHT-WIDTH: 0px" height=182 alt=entity7 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity7_thumb.jpg" width=240 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity7_thumb.jpg"&gt;&lt;/A&gt;Then when accessing the customers data you need to remember to call the GetCustomers method and not access the Customers directly in the DataContext, otherwise you'll get a SQLException that it cant find the additional columns when retrieving the data (in our case EmailAddress and Phone). &lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Private &lt;/SPAN&gt;db &lt;SPAN style="COLOR: blue"&gt;As New &lt;/SPAN&gt;MyDataContext

&lt;SPAN style="COLOR: blue"&gt;Private Sub&lt;/SPAN&gt;Form1_Load() &lt;SPAN style="COLOR: blue"&gt;Handles MyBase&lt;/SPAN&gt;.Load&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&lt;SPAN style="COLOR: green"&gt;    'This will properly populate a collection of our&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;    ' Customer entities.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;    &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.CustomerBindingSource.DataSource = db.GetCustomers
&lt;SPAN style="COLOR: blue"&gt;End Sub&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;To save the data in a connected state like this we can simply call SubmitChanges on the DataContext. The LINQ to SQL DataContext tracks the state of each modification, deletion or insertion into the collection of Customers and will call the corresponding stored procedures that we configured.&lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Private Sub &lt;/SPAN&gt;CustomerBindingNavigatorSaveItem_Click() _
   &lt;SPAN style="COLOR: blue"&gt;Handles &lt;/SPAN&gt;CustomerBindingNavigatorSaveItem.Click
   &lt;SPAN style="COLOR: blue"&gt;Try
       &lt;/SPAN&gt;db.SubmitChanges()

       MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"saved"&lt;/SPAN&gt;)
   &lt;SPAN style="COLOR: blue"&gt;Catch &lt;/SPAN&gt;ex &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;Exception
       MsgBox(ex.ToString)
   &lt;SPAN style="COLOR: blue"&gt;End Try
End Sub&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;(Note: In order to get get drag-drop data binding in Windows Forms to work with LINQ to SQL objects you need to select Data --&amp;gt; "Add New Data Source" on the main menu, then select Object (not database). Then select the Customer object and Finish. This will populate your Data Sources window so you can drag the grid onto a Windows form.)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Entity Splitting Using the Entity Data Model&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This scenario becomes pretty straight-forward and automatic using the &lt;A href="http://msdn.microsoft.com/en-us/library/bb399183.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb399183.aspx"&gt;Entity Framework (EF)&lt;/A&gt; and you're not required to write any stored procedures to get it to work. This is because EF provides more complex mappings out of the box than LINQ to SQL or DataSets. And EF separates your database schema from your object model by providing a mapping layer. If you have &lt;A href="http://msdn.microsoft.com/en-us/vstudio/products/cc533448.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/vstudio/products/cc533448.aspx"&gt;Visual Studio 2008 Service Pack 1&lt;/A&gt; you can create what's called an Entity Data Model which provides an ObjectContext, similar in theory to the LINQ to SQL DataContext above, but it provides many &lt;A href="http://msdn.microsoft.com/en-us/library/cc716779.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc716779.aspx"&gt;more mapping features&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;When you add a new Entity Data Model to your project you can choose to generate it from the database or you can create an empty model. For this example I'll choose to generate it from the database and I'll select just the Customer and CustomerContactInfo tables and no stored procedures this time. (Note that I can still map stored procs to the update, insert and delete behaviors if I need to though.)&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity8_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity8_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=289 alt=entity8 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity8_thumb.jpg" width=479 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity8_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;This looks just like our database model except you can see the navigation properties displayed that let us navigate from one entity to related ones. Notice the association is also shown as one-to-(none or)one. To set up the mapping so that it will automatically split the entity for us first we need to adjust the Customer by adding the EmailAddress and Phone. You can select the EmailAddress and Phone properties of the CustomerContactInfo and cut then paste them into the Customer. Then you can delete the CustomerContactInfo class from the design surface. &lt;/P&gt;
&lt;P&gt;Now select the Customer and look at the Mapping Details window. Below the column mappings you will see &amp;lt;Add a Table or View&amp;gt;. Drop that down and select CustomerContactInfo and it will automatically map the columns in that table to the properties that we added.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity9_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity9_2.jpg"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=359 alt=entity9 src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity9_thumb.jpg" width=640 border=0 mce_src="http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/EditingDatafromTwoTablesinaSingleDataGri_D9C4/entity9_thumb.jpg"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Save the model and rebuild the project. Now you can add Customer as a data source for drag-drop Winforms data binding the same way you do for LINQ to SQL classes or your own objects. And the code for loading and saving of the Customers is similar to the LINQ to SQL code above except loading the Customers is much more intuitive. And the ObjectContext tracks changes for you and generates the proper insert, update, and delete statements automatically without you having to define stored procedures to do the splitting. &lt;/P&gt;&lt;PRE class=code&gt;&lt;SPAN style="COLOR: blue"&gt;Private &lt;/SPAN&gt;db &lt;SPAN style="COLOR: blue"&gt;As New &lt;/SPAN&gt;MyDatabaseEntities

&lt;SPAN style="COLOR: blue"&gt;Private Sub &lt;/SPAN&gt;Form1_Load() &lt;SPAN style="COLOR: blue"&gt;Handles MyBase&lt;/SPAN&gt;.Load

    &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.CustomerBindingSource.DataSource = db.Customer
&lt;SPAN style="COLOR: blue"&gt;End Sub

Private Sub &lt;/SPAN&gt;CustomerBindingNavigatorSaveItem_Click() _
    &lt;SPAN style="COLOR: blue"&gt;Handles &lt;/SPAN&gt;CustomerBindingNavigatorSaveItem.Click

    &lt;SPAN style="COLOR: blue"&gt;Try
        &lt;/SPAN&gt;db.SaveChanges()

        MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"saved"&lt;/SPAN&gt;)
    &lt;SPAN style="COLOR: blue"&gt;Catch &lt;/SPAN&gt;ex &lt;SPAN style="COLOR: blue"&gt;As &lt;/SPAN&gt;Exception
        MsgBox(ex.ToString)
    &lt;SPAN style="COLOR: blue"&gt;End Try
End Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;A href="http://11011.net/software/vspaste" mce_href="http://11011.net/software/vspaste"&gt;&lt;/A&gt;
&lt;P&gt;This is just the tip of the iceberg using the Entity Data Model. I'd recommend reading the &lt;A href="http://msdn.microsoft.com/en-us/library/bb399572.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb399572.aspx"&gt;documentation in the MSDN library&lt;/A&gt;, visiting the &lt;A href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=533&amp;amp;SiteID=1" target=_blank mce_href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=533&amp;amp;SiteID=1"&gt;forums&lt;/A&gt; and the &lt;A href="http://blogs.msdn.com/dsimmons/pages/entity-framework-faq.aspx" target=_blank mce_href="http://blogs.msdn.com/dsimmons/pages/entity-framework-faq.aspx"&gt;FAQ&lt;/A&gt;, as well as visiting &lt;A href="http://learnentityframework.com/events" target=_blank mce_href="http://learnentityframework.com/events"&gt;Julie Lerman's site&lt;/A&gt; (she's been living EF since the early Betas). I'm just learning EF myself but as you can see it allows you to model more complex data scenarios. &lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9001289" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Winforms/default.aspx">Winforms</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>Enabling Remote SQL Express 2008 Network Connections on Vista</title><link>http://blogs.msdn.com/bethmassi/archive/2008/09/17/enabling-remote-sql-express-2008-network-connections-on-vista.aspx</link><pubDate>Thu, 18 Sep 2008 05:30:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8956539</guid><dc:creator>Beth Massi</dc:creator><slash:comments>33</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/8956539.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=8956539</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=8956539</wfw:comment><description>&lt;p&gt;Today I spent way too long trying to enable remote network connections on my SQL 2008 Express database running on my Vista development machine so I thought I'd post the steps here. Please note that these settings may NOT be appropriate for your production environments. I'm a developer ;-), hence this is what I did to get the development environment working. If you need to set up production environments I'd read the &lt;a href="http://msdn.microsoft.com/en-us/library/bb522543.aspx" target="_blank"&gt;SQL Server Books online&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Normally when developing code I always use the local SQL Express instance on my box and the default install takes care of everything so local connections via Visual Studio work fine. But what I was doing today was trying to connect a VPC to SQL 2008 Express on my host development machine in order to test some apps, simulating a network. When installing SQL 2005 or 2008 Express it locks out remote access to be on the safe side. Here's the basic steps you need to do to get it working:&lt;/p&gt;  &lt;p&gt;1. &lt;strong&gt;Open up the SQL Server Configuration Manager. &lt;/strong&gt;Programs / Microsoft SQL Server 2008 / Configuration Tools / SQL Server Configuration Manager. &lt;/p&gt;  &lt;p&gt;2. &lt;strong&gt;Expand&lt;/strong&gt; the SQL Server Network Configuration node and select the Protocols for SQLEXPRESS&lt;/p&gt;  &lt;p&gt;3. &lt;strong&gt;Enable TCP/IP&lt;/strong&gt; by right-clicking and selecting Enable, then OK.&lt;/p&gt;  &lt;p&gt;4. Click on the SQL Server Services node and in the right panel right-click SQL Server (EXPRESS) and select restart to &lt;strong&gt;restart the service&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;5. Right-click on the SQL Server Browser and select start to &lt;strong&gt;start the browser service&lt;/strong&gt; if it isn't started already. This will allow you to access the SQL Express instance by the computer name.&lt;/p&gt;  &lt;p&gt;6. &lt;strong&gt;Open up SQL Server Management Studio as Administrator&lt;/strong&gt;. (If you don't have SSMS installed, &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7522a683-4cb2-454e-b908-e805e9bd4e28&amp;amp;DisplayLang=en" target="_blank"&gt;get it here&lt;/a&gt;)&lt;/p&gt;  &lt;p&gt;7. In the Object Explorer under the Security node, &lt;strong&gt;add a new user&lt;/strong&gt; for the account that will be connecting by right-clicking and selecting &amp;quot;New User&amp;quot;. This opens the Login Properties page. If you're on a domain then use Windows Authentication. For my VPC scenario it wasn't connected to a domain so I added a SQL Server login and password. (To enable SQL logins you need to first right-click on the SQL Express instance at the top, select Properties and under Security select &amp;quot;SQL Server and Windows Authentication mode&amp;quot;.) &lt;/p&gt;  &lt;p&gt;8. Select User Mapping on the Login Properties and &lt;strong&gt;check off the database you want to connect to&lt;/strong&gt;. If you're just testing then you can select db_owner in the role membership to grant all access to the database, including altering the schema. Please note that this is &lt;strong&gt;not secure&lt;/strong&gt; but it works for development and testing. &lt;/p&gt;  &lt;p&gt;If you want to be secure you can go and specifically grant permissions under the Security node for the specific database back up in the Object Explorer. But if you're on a domain then I would recommend creating a least privileged Windows Security Group on your domain and adding that to a SQL Server Role that you can configure explicit permissions on (i.e. GRANT EXECUTE on your CRUD stored procs and GRANT SELECT on tables, don't let DELETE, INSERT and UPDATE directly). Then you can just use normal Windows security to add users on the domain to the group. This also lets you use integrated security in the connection strings which is much more secure. &lt;/p&gt;  &lt;p&gt;9. &lt;strong&gt;Configure the Firewall. &lt;/strong&gt;This is the step that I forgot and was banging my head on the wall 4-EV-R! Open up Windows Firewall and select Change Settings, select the Exceptions Tab and click Add Program. You'll need to select the SQLServer.exe in Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\ and the SQLBrowser.exe in Program Files\Microsoft SQL Server\90\Shared\. Then select Properties for each of them and select the &amp;quot;Change Scope&amp;quot; button. Then select the proper scope. For development and testing you could specify the remote computer's IP address or widen it to your network subnet. I recommend not allowing Internet users. ;-)&lt;/p&gt;  &lt;p&gt;&lt;img src="http://blogs.msdn.com/photos/bethmassi/images/8956528/583x480.aspx" /&gt; &lt;/p&gt;  &lt;p&gt;10. &lt;strong&gt;Configure the connection string. &lt;/strong&gt;Now back in Visual Studio you can configure your connection string settings in your Project Settings (app.config). If you used Windows Authentication then it's really easy:&lt;/p&gt;  &lt;pre class="code"&gt;Data Source=SERVERNAME\sqlexpress;Initial Catalog=MyDatabase;Integrated Security=True&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;If you used a SQL Login then you need to supply a less secure connection string with the username and password:&lt;/p&gt;

&lt;pre class="code"&gt;Data Source=SERVERNAME\sqlexpress;Initial Catalog=MyDatabase;User ID=username;Password=password&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;I hope that works for you, it did for me. If you're still having trouble please see these &lt;a href="http://msdn.microsoft.com/en-us/library/ms190944.aspx" target="_blank"&gt;troubleshooting tips in the library&lt;/a&gt; or ask a question on the &lt;a href="http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=19&amp;amp;SiteID=1" target="_blank"&gt;SQL Server forums&lt;/a&gt;. I'm by no means an expert in SQL Server configuration or networks. &lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8956539" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>What's New in Visual Studio 2008 SP1 - Client and Data Features</title><link>http://blogs.msdn.com/bethmassi/archive/2008/09/11/what-s-new-in-vs-2008-sp1-client-and-data-features.aspx</link><pubDate>Thu, 11 Sep 2008 22:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8945327</guid><dc:creator>Beth Massi</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/8945327.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=8945327</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=8945327</wfw:comment><description>&lt;P&gt;Last night I spoke at &lt;A href="http://www.baynetug.org/DesktopDefault.aspx?tabindex=1&amp;amp;tabid=26" target=_blank mce_href="http://www.baynetug.org/DesktopDefault.aspx?tabindex=1&amp;amp;tabid=26"&gt;East Bay.NET UG&lt;/A&gt; on some of the new features in &lt;A href="http://msdn.microsoft.com/en-us/vstudio/products/cc533448.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/vstudio/products/cc533448.aspx"&gt;Visual Studio Service Pack 1&lt;/A&gt; focusing on client and data. I did a whirlwind tour of &lt;A href="http://technet.microsoft.com/en-us/magazine/cc434692.aspx" target=_blank mce_href="http://technet.microsoft.com/en-us/magazine/cc434692.aspx"&gt;new SQL 2008 data types&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/bb726018.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb726018.aspx"&gt;Sync Services enhancements&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/bb399572.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/bb399572.aspx"&gt;ADO.NET Entity Framework&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/cc907912.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc907912.aspx"&gt;ADO.NET Data Services&lt;/A&gt;, WPF &lt;A href="http://blogs.msdn.com/jgoldb/archive/2008/05/15/what-s-new-for-performance-in-wpf-in-net-3-5-sp1.aspx" target=_blank mce_href="http://blogs.msdn.com/jgoldb/archive/2008/05/15/what-s-new-for-performance-in-wpf-in-net-3-5-sp1.aspx"&gt;performance&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.data.bindinglistcollectionview.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.windows.data.bindinglistcollectionview.aspx"&gt;data enhancements&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/library/cc656912.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc656912.aspx"&gt;Client Profile Deployment&lt;/A&gt;, VSTO Add-In &lt;A href="http://msdn.microsoft.com/en-us/library/x97a5x3s.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/x97a5x3s.aspx"&gt;Host Controls&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/ms178786.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms178786.aspx"&gt;Smart Tags&lt;/A&gt;, and VSTO &lt;A href="http://msdn.microsoft.com/en-us/library/3295w01c.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/3295w01c.aspx"&gt;deployment&lt;/A&gt; and &lt;A href="http://msdn.microsoft.com/en-us/library/cc442816.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc442816.aspx"&gt;end-user install troubleshooting&lt;/A&gt; improvements. There is just so much packed into SP1 that next month we'll be doing a talk on all things web including &lt;A href="http://msdn.microsoft.com/en-us/library/cc488546.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/cc488546.aspx"&gt;ASP.NET Dynamic Data&lt;/A&gt; and &lt;A href="http://www.asp.net/mvc/" target=_blank mce_href="http://www.asp.net/mvc/"&gt;MVC&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;The talk went really well and it was a lot of fun. I've uploaded the presentation and demos onto Code Gallery here: &lt;A title=http://code.msdn.microsoft.com/whatsnewvs2008sp1 href="http://code.msdn.microsoft.com/whatsnewvs2008sp1" mce_href="http://code.msdn.microsoft.com/whatsnewvs2008sp1"&gt;http://code.msdn.microsoft.com/whatsnewvs2008sp1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8945327" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Speaking/default.aspx">Speaking</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/ClickOnce/default.aspx">ClickOnce</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Entity+Framework/default.aspx">Entity Framework</category></item><item><title>Channel 9 Interview: SQL 2008 &amp; Occasionally Connected Client Support in Visual Studio SP1</title><link>http://blogs.msdn.com/bethmassi/archive/2008/08/08/channel-9-interview-sql-2008-occasionally-connected-client-support-in-visual-studio-sp1.aspx</link><pubDate>Sat, 09 Aug 2008 03:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8844575</guid><dc:creator>Beth Massi</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/8844575.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=8844575</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=8844575</wfw:comment><description>&lt;P&gt;&lt;A href="http://channel9.msdn.com/posts/funkyonex/SQL-2008--Occasionally-Connected-Client-Support-in-Visual-Studio-SP1/" target=_blank mce_href="http://channel9.msdn.com/posts/funkyonex/SQL-2008--Occasionally-Connected-Client-Support-in-Visual-Studio-SP1/"&gt;I just posted a new Channel 9 interview&lt;/A&gt; with Milind Lele, a PM on the VS Pro Tools team. In this interview Milind shows us the improvements made to the tooling in Visual Studio SP1 for occasionally connected clients as well as the new data type support for SQL Server 2008. &lt;/P&gt;
&lt;P&gt;Using SQL 2008 built-in change tracking, you don't need to make modifications to your table schemas like you have to do with SQL 2005. Additionally he shows off a "smarter" DataSet designer where you can have tables coming from server and client data stores all contained within one model making maintenance easier.&lt;/P&gt;&lt;IFRAME src="http://channel9.msdn.com/posts/funkyonex/420516/player/" frameBorder=0 width=320 scrolling=no height=325 mce_src="http://channel9.msdn.com/posts/funkyonex/420516/player/"&gt;&lt;/IFRAME&gt;&lt;BR&gt;&lt;A href="http://channel9.msdn.com/posts/funkyonex/SQL-2008--Occasionally-Connected-Client-Support-in-Visual-Studio-SP1/" mce_href="http://channel9.msdn.com/posts/funkyonex/SQL-2008--Occasionally-Connected-Client-Support-in-Visual-Studio-SP1/"&gt;SQL 2008 &amp;amp; Occasionally Connected Client Support in Visual Studio SP1&lt;/A&gt; &lt;BR&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8844575" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Channel9/default.aspx">Channel9</category></item><item><title>Support for SQL 2008 Data Types Coming into LINQ to SQL</title><link>http://blogs.msdn.com/bethmassi/archive/2008/02/22/support-for-sql-2008-data-types-coming-into-linq-to-sql.aspx</link><pubDate>Sat, 23 Feb 2008 04:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7852669</guid><dc:creator>Beth Massi</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/7852669.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=7852669</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=7852669</wfw:comment><description>&lt;P&gt;Check it out, on the &lt;A class="" href="http://blogs.msdn.com/adonet/default.aspx" target=_blank mce_href="http://blogs.msdn.com/adonet/default.aspx"&gt;ADO.NET Team blog&lt;/A&gt; Faisal Mohamood, a PM on the LINQ to SQL team, &lt;A class="" href="http://blogs.msdn.com/adonet/archive/2008/02/21/coming-soon-to-linq-to-sql.aspx" target=_blank mce_href="http://blogs.msdn.com/adonet/archive/2008/02/21/coming-soon-to-linq-to-sql.aspx"&gt;posted on the new features&lt;/A&gt; you can expect to see added to LINQ to SQL. This includes support for new data types coming in SQL 2008.&lt;/P&gt;
&lt;P&gt;Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7852669" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>Resizing Images Stored in SQL-Server</title><link>http://blogs.msdn.com/bethmassi/archive/2007/08/28/rezising-images-stored-in-sql-server.aspx</link><pubDate>Tue, 28 Aug 2007 21:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4616925</guid><dc:creator>Beth Massi</dc:creator><slash:comments>23</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/4616925.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=4616925</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=4616925</wfw:comment><description>&lt;P&gt;In SQL-Server we can store images inside database tables directly&amp;nbsp;using the Image column type. And with .NET 2.0 data binding it can automatically convert these images (stored as byte arrays) into System.Drawing.Image classes for you. For instance,&amp;nbsp;say you have a table called Pictures that has a column called Picture of the data type Image. You can create a new data source to this table to generate a strongly typed DataSet and use drag-and drop data binding to automatically display the image in a PictureBox. (For information on connecting to your database and creating strongly typed DataSets &lt;A class="" href="http://msdn2.microsoft.com/en-us/vbasic/bb643826.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/vbasic/bb643826.aspx"&gt;watch this video&lt;/A&gt;.) &lt;/P&gt;
&lt;P&gt;If you don't see a PictureBox icon in the Data Sources window next to the Picture column in your DataTable, you may need to select the PictureBox to associate the byte array with the control:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG style="WIDTH: 228px; HEIGHT: 306px" height=306 src="http://blogs.msdn.com/photos/bethmassi/images/4616617/original.aspx" width=228 mce_src="http://blogs.msdn.com/photos/bethmassi/images/4616617/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;Now you can drag-and-drop the Picture onto your form to set up the data binding to the PictureBox. The&amp;nbsp;binding will automatically handle converting the byte array stored in the column into an image using the System.Drawing.ImageConverter. You can then set the SizeMode property on the PictureBox depending on how you want the image displayed; resized, stretched or otherwise. &lt;/P&gt;
&lt;P&gt;But what if you just want to resize the image and not use a PictureBox? In that case you just need to convert the byte array stored in the Picture column into an System.Drawing.Image. Once you have that then you can use methods on this Image class to perform all sorts of transformations. To resize the image,&amp;nbsp;just call GetThumbnailImage and pass it the new size requirements:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; resizeImg, origImg &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; Image&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;'Get the current row&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; row &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; PictureDemoDataSet.PictureRow&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;row = &lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.PictureBindingSource.Current, DataRowView).Row, _&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PictureDemoDataSet.PictureRow)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;'Convert byte array to image&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Using&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; ms &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.IO.MemoryStream(row.Picture)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;origImg = Image.FromStream(ms)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; width &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 25&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; height &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 25&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;'Resize image&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;resizeImg = origImg.GetThumbnailImage(width, height, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Using&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/bethmassi/attachment/4616925.ashx" mce_href="http://blogs.msdn.com/bethmassi/attachment/4616925.ashx"&gt;I've attached a simple application&lt;/A&gt; that demonstrates these techniques for you to play with. You'll need Visual Basic 2005 and SQL Server 2005 (or Express) to run.&lt;/P&gt;
&lt;P&gt;Enjoy!&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4616925" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/bethmassi/attachment/4616925.ashx" length="3485751" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Winforms/default.aspx">Winforms</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>Building a Secure Login Form (Parameterized Queries Part 2)</title><link>http://blogs.msdn.com/bethmassi/archive/2007/06/06/login-form-parameterized-queries-part-2.aspx</link><pubDate>Thu, 07 Jun 2007 08:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2993852</guid><dc:creator>Beth Massi</dc:creator><slash:comments>27</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/2993852.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=2993852</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=2993852</wfw:comment><description>&lt;P&gt;&lt;A class="" href="http://blogs.msdn.com/bethmassi/archive/2007/05/25/creating-a-parameterized-query.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2007/05/25/creating-a-parameterized-query.aspx"&gt;In my first post on&amp;nbsp;parameterized queries&lt;/A&gt;&amp;nbsp;I built a simple login form that really was a contrived example meant to showcase how to use the &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/dex7k4dw(VS.80).aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/dex7k4dw(VS.80).aspx"&gt;TableAdapter Configuration Wizard&lt;/A&gt; to configure a parameterized query. However, since I opened myself up here, I felt it socially responsible to show how to make this a bit more secure by showing you how to store passwords in a secure way in a database. &lt;/P&gt;
&lt;P&gt;There are actually many many secure ways to store data in your database including using the &lt;A class="" href="http://aspnet.4guysfromrolla.com/articles/021407-1.aspx" target=_blank mce_href="http://aspnet.4guysfromrolla.com/articles/021407-1.aspx"&gt;encryption features of SQL-Server 2005&lt;/A&gt;&amp;nbsp;which allows you to protect columns inside your database at the database level, independent of the application. Additionally, if we're just talking about user's logins and you're building a multi-tier or SO application then using the ASP.NET membership services is probably your best choice.&lt;A class="" href="http://blogs.msdn.com/brada/archive/2007/05/23/net-client-application-services.aspx" target=_blank mce_href="http://blogs.msdn.com/brada/archive/2007/05/23/net-client-application-services.aspx"&gt; In next version of Visual Studio, Microsoft made these ASP.NET services easily&amp;nbsp;accessible to any client application&lt;/A&gt; (Winforms, WPF, Silverlight) not just WebForms. But what if you're building a single-user application or a client-server app with only a handful of users and you don't have (or want) a web server or maybe you're not using SQL-Server as your database? &lt;/P&gt;
&lt;P&gt;The first recommendation for this scenario is don't store passwords at all. If you don't have passwords in your application then you don't have to worry about someone stealing them. Instead, consider using the Windows Identity as the user of your application. This means that your application will not need to store passwords, only user names, because it would be using the logged in Windows user which has already been authenticated through the Windows OS. To access the user name of the currently logged in user from your client code:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Imports&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; System.Security.Principal&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;...&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; user &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt;&lt;FONT color=#000000&gt; WindowsIdentity = WindowsIdentity.GetCurrent()&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; userName &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;&lt;FONT color=#000000&gt; = user.Name&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P&gt;The only thing you would need to do in your database Login table is make the UserName field unique. Then you could write a very simple parameterized query. &lt;/P&gt;
&lt;P&gt;SELECT COUNT(*) FROM Login WHERE UserName = @UserName&lt;/P&gt;
&lt;P&gt;So your login code would be very simple. If you name the above parameterized query on your TableAdapter "GetLoginByUserName" then it would be something like:&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Imports&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; System.Security.Principal&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;...&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; user &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt;&lt;FONT color=#000000&gt; WindowsIdentity = WindowsIdentity.GetCurrent()&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; userName &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;&lt;FONT color=#000000&gt; = user.Name&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;If&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;&lt;FONT color=#000000&gt;(&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;&lt;FONT color=#000000&gt;.LoginTableAdapter1.GetLoginByUserName(userName), &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;&lt;FONT color=#000000&gt;) = 1 &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;/FONT&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Welcome to my application!"&lt;/SPAN&gt;&lt;FONT color=#000000&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;/FONT&gt;&lt;SPAN style="COLOR: #a31515"&gt;"Invalid username or password."&lt;/SPAN&gt;&lt;FONT color=#000000&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;/SPAN&gt;(NOTE: This code assumes that the application is connecting to the database directly and not through a service layer. If you are connecting to a service layer then you need to configure your web server to authenticate Windows users by not allowing anonymous access and only allowing Windows Authentication. &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/aa480475.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/aa480475.aspx"&gt;For more information, read this&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;However, what if you cannot use this method of authentication?&amp;nbsp;For instance,&amp;nbsp;your application runs on a shared&amp;nbsp;computer that&amp;nbsp;remains logged in under one Windows&amp;nbsp;login, but you require users to login separately to your application. In that case you're going to need to store passwords. However, if we store passwords as clear text in our database, anybody that can get a glimpse of the&amp;nbsp;Login table will have a bunch of user credentials to access the application! The safest thing to do is to use a one-way hashing algorithm and store the hashes in your database table instead. The .NET Framework gives you a lot of help here by providing a handful of proven hashing algorithms in the &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.aspx"&gt;System.Security.Cryptography&lt;/A&gt; namespace. The most common are &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.sha1.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.sha1.aspx"&gt;SHA-1&lt;/A&gt; and &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.md5.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.md5.aspx"&gt;MD5&lt;/A&gt;. To hash a string using the SHA-1 becomes very simple in .NET:&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Imports&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; System.Security.Cryptography&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Imports&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; System.Text&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;...&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; HashEncryptString(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; s &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; hasher &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; SHA1CryptoServiceProvider()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; clearBytes &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Byte&lt;/SPAN&gt;() = Encoding.UTF8.GetBytes(s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; hashedBytes &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Byte&lt;/SPAN&gt;() = hasher.ComputeHash(clearBytes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; Convert.ToBase64String(hashedBytes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Hash algorithms are one-way so it's very very difficult to tell what the original password is from a computed hash. (So if a user forgets their password, you won't be able to tell them what it was.) So when we store user names and passwords in our Login table we can easily hash the value of the submitted password and store that instead. So we're secure now, right? Well almost! Let's take a look at my Login table in this example:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG style="WIDTH: 471px; HEIGHT: 152px" height=152 src="http://blogs.msdn.com/photos/bethmassi/images/3132451/original.aspx" width=471 mce_src="http://blogs.msdn.com/photos/bethmassi/images/3132451/original.aspx"&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Notice that Beth and Joe both have the &lt;EM&gt;same hashed password&lt;/EM&gt;. This means that both these passwords are the same as clear text as well. An attacker could probably figure out the password by using a &lt;A class="" href="http://en.wikipedia.org/wiki/Dictionary_attack" target=_blank mce_href="http://en.wikipedia.org/wiki/Dictionary_attack"&gt;dictionary attack&lt;/A&gt; on our table. So what can we do?&lt;/P&gt;
&lt;P mce_keep="true"&gt;There's a technique called &lt;EM&gt;salting &lt;/EM&gt;where you take the password and "salt" it with a random value and then hash that. This random value is different for each login. This will create different hashed passwords for the same clear text password, making it extremely difficult to break. To be even more secure, you should store this salt value in a separate table from the passwords. To obtain an appropriate&amp;nbsp;salt (random) value&amp;nbsp;in .NET you can use the &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx"&gt;RNGCryptoServiceProvider&lt;/A&gt;&amp;nbsp;class. &lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Imports&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; System.Security.Cryptography&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Function&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; GetSalt(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; saltSize &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; buffer() &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Byte&lt;/SPAN&gt; = &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Byte&lt;/SPAN&gt;(saltSize) {}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; rng &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; RNGCryptoServiceProvider()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;rng.GetBytes(buffer)&lt;BR&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; Convert.ToBase64String(buffer)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;
&lt;P mce_keep="true"&gt;So now we can take the salt value and store that in a table called Salt which has a foreign key to our Login table. Then I can create a couple parameterized queries on my TableAdapters for Login and Salt.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG src="http://blogs.msdn.com/photos/bethmassi/images/3132890/340x375.aspx" mce_src="http://blogs.msdn.com/photos/bethmassi/images/3132890/340x375.aspx"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;On the LoginTableAdapter we can add a parameterized query called GetLoginByUserNameAndPassword where we pass the UserName and the salted hashed password. The select statement returns a scalar value and we add it through the TableAdapter Query Configuration Wizard just like I &lt;A class="" href="http://blogs.msdn.com/bethmassi/archive/2007/05/25/creating-a-parameterized-query.aspx" target=_blank mce_href="http://blogs.msdn.com/bethmassi/archive/2007/05/25/creating-a-parameterized-query.aspx"&gt;showed in my previous post&lt;/A&gt;.&lt;/P&gt;
&lt;P mce_keep="true"&gt;SELECT COUNT(*) FROM Login WHERE UserName = @UserName AND Password = @Password&lt;/P&gt;
&lt;P mce_keep="true"&gt;In order to pass the correct value for the @Password parameter, we need the salt value first. On the SaltTableAdapter we can add a parameterized query that returns the salt value for a given UserName called GetSaltByUserName.&lt;/P&gt;
&lt;P mce_keep="true"&gt;SELECT TOP (1) Salt.Salt FROM&amp;nbsp;Salt INNER JOIN&amp;nbsp;Login ON Salt.LoginID = Login.LoginID WHERE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Login.UserName = @UserName)&lt;/P&gt;
&lt;P mce_keep="true"&gt;To make it easier to access the hashing functions we can create a module called PasswordCrypto:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Imports&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; System.Security.Cryptography&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Imports&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;/SPAN&gt;System.Text&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Module&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; PasswordCrypto&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; Hasher &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; SHA1CryptoServiceProvider()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Friend&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; GetSalt(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; saltSize &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; buffer() &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Byte&lt;/SPAN&gt; = &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Byte&lt;/SPAN&gt;(saltSize) {}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; rng &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; RNGCryptoServiceProvider()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;rng.GetBytes(buffer)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; Convert.ToBase64String(buffer)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Friend&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; HashEncryptString(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; s &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; clearBytes &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Byte&lt;/SPAN&gt;() = Encoding.UTF8.GetBytes(s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; hashedBytes &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Byte&lt;/SPAN&gt;() = Hasher.ComputeHash(clearBytes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; Convert.ToBase64String(hashedBytes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Friend&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; HashEncryptStringWithSalt(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; s &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;, _&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; salt &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;BR&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; HashEncryptString(salt + s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Module&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;
&lt;P mce_keep="true"&gt;Now that we have our hashing code and our TableAdapters configured, taking our Login form we can add code like this to verify whether a user's entered password matches the hashed password in the Login table:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; isOK &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Boolean&lt;/SPAN&gt; = &lt;SPAN style="COLOR: blue"&gt;False&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;'Get the salt value for this username&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; saltValue &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;/SPAN&gt; = _&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;nbsp;&amp;nbsp;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.SaltTableAdapter1.GetSaltByUserName(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.txtUserName.Text)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Not&lt;/SPAN&gt; IsDBNull(saltValue) &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;'Hash the user entered password with the salt value stored in the Salt table&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; password &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt; = _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PasswordCrypto.HashEncryptStringWithSalt(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.txtPassword.Text, saltValue.ToString)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;'Now check the Login table to see if this hashed password matches&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;isOK =&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;CType&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.LoginTableAdapter1.GetLoginByUserNameAndPassword( _&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.txtUserName.Text, password), &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;) = 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; isOK &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"Welcome to my Application!"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"Invalid user name or password."&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Catch&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; ex &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; Exception&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;MsgBox(ex.ToString)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Try&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;So this is how we can store passwords in a secure way in our database, even if our database does not support encrypted columns. With .NET, accessing hashing algorithms is a snap. &lt;A class="" href="http://blogs.msdn.com/bethmassi/attachment/2993852.ashx" mce_href="http://blogs.msdn.com/bethmassi/attachment/2993852.ashx"&gt;I've attached a complete sample&lt;/A&gt; that demonstrates these techniques (as well as saving users passwords and salts) so that you can learn from them. You'll need Visual Studio or &lt;A class="" href="http://msdn.microsoft.com/vstudio/express/vb/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/vb/"&gt;Visual Basic Express&lt;/A&gt; and &lt;A class="" href="http://msdn.microsoft.com/vstudio/express/sql/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/sql/"&gt;SQL-Server Express&lt;/A&gt; installed to compile and run the sample.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Enjoy! And be secure!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2993852" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/bethmassi/attachment/2993852.ashx" length="179027" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2005/default.aspx">VS2005</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Winforms/default.aspx">Winforms</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>Working with a Local Data File in VS</title><link>http://blogs.msdn.com/bethmassi/archive/2007/05/29/working-with-a-local-data-file-in-vs.aspx</link><pubDate>Wed, 30 May 2007 03:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2978215</guid><dc:creator>Beth Massi</dc:creator><slash:comments>18</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/2978215.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=2978215</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=2978215</wfw:comment><description>&lt;P&gt;Visual Studio 2005 made some big improvements in the way applications work with data, from &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx"&gt;BindingSources&lt;/A&gt; to the &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/6ckyxa83(vs.80).aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/6ckyxa83(vs.80).aspx"&gt;Data Sources Window&lt;/A&gt; all the way to a free version of SQL-Server called &lt;A class="" href="http://msdn.microsoft.com/vstudio/express/sql/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/sql/"&gt;SQL-Server Express&lt;/A&gt;. I've had a few customers get stuck on using SQL-Server Express local database files with their project so I thought I'd post on how this works. &lt;/P&gt;
&lt;P&gt;The problem that people are having is that when you add a local database file to your project, VS will happily create the proper connection string for you and immediately get you connected and building DataSets, but when you run the project and save some data, then run the app again, you'll notice that your data is gone. Which means you spend time trying to debug your dataset or your connection when your data actually saved just fine.&lt;/P&gt;
&lt;P&gt;In my &lt;A class="" href="http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx"&gt;Forms over Data Videos&lt;/A&gt; I build a database from scratch which attaches&amp;nbsp;the database to my SQL-Server Express database instance. This is the same experience when creating databases on remote SQL-Servers. The actual database file is located in the Data directory under the appropriate SQL-Server instance, in my case: \\BETHFACE\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Data. However, in order to send the data with my code samples I &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/ms191491.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/ms191491.aspx"&gt;detached the database&lt;/A&gt; and added the database&amp;nbsp;MDF file into the project itself and changed the connection string in My.Settings -- at this point it became a local SQL-Server Express data file. &lt;/P&gt;
&lt;P&gt;If you look in those &lt;A class="" href="http://blogs.msdn.com/bethmassi/attachment/2431280.ashx" mce_href="http://blogs.msdn.com/bethmassi/attachment/2431280.ashx"&gt;sample projects&lt;/A&gt;, open the Solution Explorer, and look at the Properties for the MDF file you will see that the Build Action is set to Content and the Copy to Output Directory is set to Copy if Newer. (If not, tell me - I must have missed one &amp;lt;g&amp;gt;). By default, MDF files are treated like any other content file and so it is set to Copy Always. When you change it to Copy if Newer, the database file will be copied to your build output directory only if you made any schema changes to the file or modified the data in VS. This is because there are actually two copies of your MDF file (as a matter of fact there are two copies of any of your files with Build Action = Content). &lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.msdn.com/photos/bethmassi/images/2978150/259x375.aspx" mce_src="http://blogs.msdn.com/photos/bethmassi/images/2978150/259x375.aspx"&gt;&lt;/P&gt;
&lt;P&gt;One copy is in your project folder, this is the file you work with when making schema changes with the VS tools. The VS tools always use this connection. However, you'll notice that the connection in the My.Settings uses a macro called |DataDirectory| to open the connection when your app is running (AttachDBFileName=|DataDirectory|\OMS.mdf). The |DataDirectory| expands to the location the EXE is running during runtime. So because of the default behavior of always copying out content files to the build directory, your database gets copied and it just &lt;EM&gt;looks like&lt;/EM&gt; your data is not saving, sending you on a wild goose chase.&lt;/P&gt;
&lt;P&gt;Just remember to mark your databases as&amp;nbsp;Copy if Newer that way you only "lose" data when you make changes to the structure of the database itself or if you add data via the Visual Studio designers. &lt;A class="" href="https://blogs.msdn.com/smartclientdata/archive/2005/08/26/456886.aspx" target=_blank mce_href="https://blogs.msdn.com/smartclientdata/archive/2005/08/26/456886.aspx"&gt;For more information check out this post as well.&lt;/A&gt;&amp;nbsp;I'll be creating a video on how to work with local database files including how to deploy them to your users in the next series.&lt;/P&gt;
&lt;P mce_keep="true"&gt;UPDATE: &lt;A class="" href="http://msdn2.microsoft.com/en-us/vbasic/bb643822.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/vbasic/bb643822.aspx"&gt;Here's that video - #10&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2978215" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2005/default.aspx">VS2005</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>Reading from a Serial Port and Saving to a Database</title><link>http://blogs.msdn.com/bethmassi/archive/2007/05/05/reading-from-a-serial-port-and-saving-to-a-database.aspx</link><pubDate>Sat, 05 May 2007 19:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2430899</guid><dc:creator>Beth Massi</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/2430899.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=2430899</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=2430899</wfw:comment><description>&lt;P&gt;Recently I was sent a question about how to read from a serial port and save the information to a database so instead of following up privately I thought I'd post my answer here. There's a &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/ms364066(vs.80).aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/ms364066(vs.80).aspx"&gt;good article in the MSDN Library&lt;/A&gt; that has some hints on how to do this with the &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.aspx"&gt;System.IO.Ports.SerialPort&lt;/A&gt; class. In Visual Basic 2005 you can use the &lt;A class="" href="http://msdn.microsoft.com/msdnmag/issues/06/00/VisualBasic2005/default.aspx" target=_blank mce_href="http://msdn.microsoft.com/msdnmag/issues/06/00/VisualBasic2005/default.aspx"&gt;My Namespace&lt;/A&gt; to access the ports on your computer easily. For instance, you can open a port to COM4 like this:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt; &lt;SPAN style="COLOR: blue"&gt;WithEvents&lt;/SPAN&gt; mySerialport &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; SerialPort&lt;/SPAN&gt;&lt;BR&gt;mySerialport = &lt;SPAN style="COLOR: blue"&gt;My&lt;/SPAN&gt;.Computer.Ports.OpenSerialPort(&lt;SPAN style="COLOR: #a31515"&gt;"COM4"&lt;/SPAN&gt;, 56000, Parity.None, 8, StopBits.One)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Once we open the serial port we can listen to the &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.datareceived.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.datareceived.aspx"&gt;DataReceived&lt;/A&gt; event. In my sample I just append the incomming messages to a StringBuilder and then save the string to a DataSet when we stop listening to the port. Its important to note that the DataReceived event will fire on a separate thread than your main thread. So if you need to update UI elements on a Form you need to use the &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/zyzhdc6b.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/library/zyzhdc6b.aspx"&gt;Form's Invoke method&lt;/A&gt; in order to execute code onto the UI thread. &lt;/P&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt;&lt;FONT color=#000000&gt; myStringBuilder &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt;&lt;FONT color=#000000&gt; StringBuilder&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; mySerialport_DataReceived(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.IO.Ports.SerialDataReceivedEventArgs) &lt;SPAN style="COLOR: blue"&gt;Handles&lt;/SPAN&gt; mySerialport.DataReceived&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;'This happens on another thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;myStringBuilder.Append(mySerialport.ReadExisting())&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.Invoke(&lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; EventHandler(&lt;SPAN style="COLOR: blue"&gt;AddressOf&lt;/SPAN&gt; UpdateControls))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; UpdateControls(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; EventArgs)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;'Do any UI code here on the main thread&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.TextBox1.Text = myStringBuilder.ToString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I just created a simple &lt;A class="" href="http://msdn.microsoft.com/vstudio/express/sql/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/sql/"&gt;SQL-Server Express&lt;/A&gt; database with one table called Message that has a field called Message. I then created a DataSet called MessageDataSet with the one MessageDataTable and then dropped that onto a grid onto my form to hook up some data binding automatically. When we stop reading from the serial port I just add a new MessageRow and then save it back using the MessageTableAdapter.Update() method.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; Stop_Click(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.Object, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.EventArgs) &lt;SPAN style="COLOR: blue"&gt;Handles&lt;/SPAN&gt; btnStopRead.Click&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; mySerialport &lt;SPAN style="COLOR: blue"&gt;IsNot&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;mySerialport.Close()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; message &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; MessageDataSet.MessageRow = &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.MessageDataSet.Message.NewMessageRow()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;message.Message = myStringBuilder.ToString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.MessageDataSet.Message.Rows.Add(message)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.Save()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;myStringBuilder.Remove(0, myStringBuilder.Length)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;.TextBox1.Text = &lt;SPAN style="COLOR: #a31515"&gt;""&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Catch&lt;/SPAN&gt; ex &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; Exception&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Try&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt;&lt;FONT color=#000000&gt; Save()&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;&lt;FONT color=#000000&gt;.Validate()&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;&lt;FONT color=#000000&gt;.MessageBindingSource.EndEdit()&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;&lt;FONT color=#000000&gt;.MessageTableAdapter.Update(&lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;&lt;FONT color=#000000&gt;.MessageDataSet.Message)&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;FONT color=#000000&gt; &lt;/FONT&gt;&lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;It's kind of hard to test hardware without hardware so if you don't have the hardware setup it's suggested that you get a &lt;A class="" href="http://www.buyextras.com/numoaddb9fef.html" target=_blank mce_href="http://www.buyextras.com/numoaddb9fef.html"&gt;null modem&lt;/A&gt; and hook that up between two USB to Serial converters to simulate two ports, one read one write. Unfortunately I don't have a null modem so I couldn't fully test my code. I've &lt;A class="" href="http://blogs.msdn.com/bethmassi/attachment/2430899.ashx" mce_href="http://blogs.msdn.com/bethmassi/attachment/2430899.ashx"&gt;attached the entire solution&lt;/A&gt; to this post, you just need &lt;A class="" href="http://msdn.microsoft.com/vstudio/express/vb/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/vb/"&gt;Visual Basic Express&lt;/A&gt; (or Visual Studio) and &lt;A class="" href="http://msdn.microsoft.com/vstudio/express/sql/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/sql/"&gt;SQL-Server Express&lt;/A&gt;&amp;nbsp;to run the example. If anyone has the hardware setup for this and finds a bug, please let me know and I'll post any corrections. You can also &lt;A class="" href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=22421&amp;amp;SiteID=1" target=_blank mce_href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=22421&amp;amp;SiteID=1"&gt;check out the forums&lt;/A&gt; for more info. Have fun!&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2430899" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/bethmassi/attachment/2430899.ashx" length="164347" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2005/default.aspx">VS2005</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Article/default.aspx">Article</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>Visual Basic How-To Video Series is Online</title><link>http://blogs.msdn.com/bethmassi/archive/2007/05/04/visual-basic-how-to-video-series-is-online.aspx</link><pubDate>Fri, 04 May 2007 21:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2413538</guid><dc:creator>Beth Massi</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/2413538.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=2413538</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=2413538</wfw:comment><description>&lt;P&gt;&lt;A class="" href="http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx"&gt;This how-to video series&lt;/A&gt; is dedicated to getting Visual Basic developers productive on areas of data-based Windows Application development. The series starts with the basics of database development with SQL-Server 2005 Express then walks through the details of connecting to and querying databases, and Windows Forms development basics using the built-in designers in Visual Basic 2005.&lt;/P&gt;
&lt;P&gt;I'm very excited to see the content I'm producing finally coming online! This series is aimed at VB.NET Winforms and database beginners&amp;nbsp;but stay tuned for more intermediate and advanced topics coming out of the Massi brain....&lt;A class="" href="http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx" target=_blank mce_href="http://msdn2.microsoft.com/en-us/vbasic/bb466226.aspx"&gt;Enjoy the series&lt;/A&gt;!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2413538" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2005/default.aspx">VS2005</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Community/default.aspx">Community</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Winforms/default.aspx">Winforms</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Videos/default.aspx">Videos</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item><item><title>SQL Server Express Video Series</title><link>http://blogs.msdn.com/bethmassi/archive/2007/04/03/sql-server-express-video-series.aspx</link><pubDate>Tue, 03 Apr 2007 13:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2020211</guid><dc:creator>Beth Massi</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/bethmassi/comments/2020211.aspx</comments><wfw:commentRss>http://blogs.msdn.com/bethmassi/commentrss.aspx?PostID=2020211</wfw:commentRss><wfw:comment>http://blogs.msdn.com/bethmassi/rsscomments.aspx?PostID=2020211</wfw:comment><description>If you're new to &lt;A class="" href="http://msdn.microsoft.com/vstudio/express/sql/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/sql/"&gt;SQL Express&lt;/A&gt;, &lt;A class="" href="http://www.microsoft.com/sql/technologies/reporting/default.mspx" target=_blank mce_href="http://www.microsoft.com/sql/technologies/reporting/default.mspx"&gt;Reporting Services&lt;/A&gt;, or databases in general, you'll want to check out the &lt;A class="" href="http://www.asp.net/learn/videos/default.aspx?tabid=63#sql" target=_blank mce_href="http://www.asp.net/learn/videos/default.aspx?tabid=63#sql"&gt;SQL Server Express video series&lt;/A&gt; up on &lt;A href="http://www.asp.net/"&gt;www.asp.net&lt;/A&gt;. I just finished watching them myself. These videos walk you through all the free tools you get with &lt;A class="" href="http://msdn.microsoft.com/vstudio/express/sql/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/sql/"&gt;SQL Server Express edition&lt;/A&gt;. They show how to design a database, setup &lt;A class="" href="http://msdn.microsoft.com/vstudio/express/sql/" target=_blank mce_href="http://msdn.microsoft.com/vstudio/express/sql/"&gt;SQL Express&lt;/A&gt; and &lt;A class="" href="http://www.microsoft.com/sql/technologies/reporting/default.mspx" target=_blank mce_href="http://www.microsoft.com/sql/technologies/reporting/default.mspx"&gt;Reporting Services&lt;/A&gt; and walk through a variety of tasks like writing stored procedures&amp;nbsp;and writing reports.&amp;nbsp;Visual Basic developers will feel at home in the Reporting Services Report Designer because the expression syntax it uses is VB script. The site also has a lot of great ASP.NET videos for beginners with plenty of Visual Basic examples. &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2020211" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Visual+Basic/default.aspx">Visual Basic</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/VS2005/default.aspx">VS2005</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://blogs.msdn.com/bethmassi/archive/tags/Data/default.aspx">Data</category></item></channel></rss>