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

How to create a DNS less linked server in Access to SQL Server.

  Sometimes you may want to use Access as a front end for SQL Server. When doing this you typically have linked tables to the SQL Server and you have the .mdb on a shared drive for users to access.   Normally you create a DSN and use that for the linked server. All works…

8

Getting metadata about dataset using lambda. Some examples.

  This may not be a massive business requirement, but if you have a bunch of DataSets and you want (for some reason) extract information about them then using Lambda and LINQ queries is one way to do it. I will let the code below speak for itself.   Sample code for meta data collection…

0

How a proper physical TCP/IP connection to SQL Server works. Network Monitor

  Not about a problem today, today will be about what a successful physical connection from client to SQL Server looks like in Network Monitor.   First download Network Monitor (currently version 3.3): “Microsoft Network Monitor 3.3” http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=983b941d-06cb-4658-b7f6-3088333d062f   . Install it on the client machine and on the SQL Server machine. . Start it….

0

Format of the initialization string does not conform to specification starting at index

Short one.   You are letting your user connect to your trusted SQL Server (fairly common scenario J) They are connecting using SQL Authentication (it is recommended to use Windows Authentication however) an intermittently the application throws an exception:   Unhandled Exception: System.ArgumentException: Format of the initialization string does not conform to specification starting at…

4