DataSet, DataTable, DataRelation, PrimaryKey template.

Sometimes I need to whip up a dataset with some tables and primary keys and relations. It’s not hard to do, but repetitive. So, here is a template that I use. Thought I’d share it.           static void Main(string[] args)         {             // Create list of columns, add/remove/rename as necessary             List<DataColumn> tbOneCols…

0

How to examine memory dump for SqlCommand.CommandText using WinDbg and SOS

  Ok, so yesterday I had a post on how to generate a dump for a SqlException.   In that scenario we had an application that was throwing an exception like so:   Unhandled Exception: System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.   …

0

How to create memory dump for SqlException using DebugDiag

  Sometimes we in support will ask you to create a dump for when your .Net client crash due to a SqlException. We do this in order to be able to find out more about the state of the process at the time of the crash.   So today I will show you the simplest…

0

Very short and simple example of using SqlMetal

A simple sample of how to use SqlMetal.   “Code Generation Tool (SqlMetal.exe)” http://msdn.microsoft.com/en-us/library/bb386987.aspx   This tool will create mappings and code for LINQ to SQL. So, as mentioned, simple and short. Create a database, some tables and insert some data.   create database VeryMetal go use VeryMetal go create table Users (UserId int primary…

3

How to see the SQL executing when updating a DataSet via DataAdapter.Update()

A fairly common question: How can I see the SQL that will be executed when updating a DataSet using a DataAdapter?   The first thing most people try is to get hold of is the Insert/Update commands for the DataAdapter. This is typically done like so (using the trusted Northwind) with CommandBuilders:               using…

0

Getting AutoNumber from Access via "SELECT @@IDENTITY" needs to be done in same connection as the INSERT.

  There are a few documents out there describing how to get the newly inserted AutoNumber in an Access table.   See for example,   “Walkthrough: Saving Data from Related Data Tables (Hierarchical Update)” http://msdn.microsoft.com/en-us/library/bb384432.aspx “Retrieving Identity or Autonumber Values (ADO.NET)” http://msdn.microsoft.com/en-us/library/ks9f57t0.aspx “HOW TO: Retrieve the Identity Value While Inserting Records into Access Database By…

2