Tips and tricks from a Developer Support perspective.

While some cases may start of as complex, they sometimes turn out to be caused by something not that complex. As the case always is once you have the solution. So I thought I would share some of the things that I've come across, and hopefully tha

Must declare the scalar variable …

“Must declare the scalar variable …” Every now and then this error is reported when using parameters...

Author: Michael Aspengren - MSFT Date: 03/03/2010

Parent/Child DataRelation. The Basics.

In short, a parent – child relation is one where (in database terms) two tables have a one-to-many...

Author: Michael Aspengren - MSFT Date: 02/18/2010

Compiling application gives : “Embedded statement cannot be a declaration or labeled statement”

I’ve seen questions like this a few times: Why doesn’t my code compile? All I do is getting a row...

Author: Michael Aspengren - MSFT Date: 02/16/2010

How to query for netstat info using PowerShell

In a few earlier posts I have mentioned that machines can run out of ports, for example: “Nested...

Author: Michael Aspengren - MSFT Date: 02/04/2010

How to create a simple Extension method. A simple example.

I’ve been trying to get my head around Extension methods. And I finally got it. Imagine for example...

Author: Michael Aspengren - MSFT Date: 01/18/2010

How to use the ObjectDataSource as a DataSource, simple example

I thought I’d give an example on how to use the ObjectDataSource in a webpage. A typical example...

Author: Michael Aspengren - MSFT Date: 01/15/2010

How to use LINQ to XML together with LINQ to SQL.

Today I’ll give you an example on how easy it is to create XML using LINQ to XML in conjunction with...

Author: Michael Aspengren - MSFT Date: 01/11/2010

How to use LINQ to SQL without using the designer generated classes

Sometimes people wonder if it is possible to use LINQ to SQL without having to use the designer and...

Author: Michael Aspengren - MSFT Date: 01/08/2010

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...

Author: Michael Aspengren - MSFT Date: 12/22/2009

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...

Author: Michael Aspengren - MSFT Date: 12/18/2009

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...

Author: Michael Aspengren - MSFT Date: 12/17/2009

Very short and simple example of using SqlMetal

A simple sample of how to use SqlMetal. "Code Generation Tool (SqlMetal.exe)"...

Author: Michael Aspengren - MSFT Date: 12/15/2009

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...

Author: Michael Aspengren - MSFT Date: 12/11/2009

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...

Author: Michael Aspengren - MSFT Date: 12/02/2009

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...

Author: Michael Aspengren - MSFT Date: 11/24/2009

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...

Author: Michael Aspengren - MSFT Date: 11/13/2009

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...

Author: Michael Aspengren - MSFT Date: 11/06/2009

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)...

Author: Michael Aspengren - MSFT Date: 10/30/2009

Why is autogenerated UPDATE and DELETE statements complex?

Sometimes people ask why the code generated for INSERT/UPDATE/DELETE is so complex, or verbose if...

Author: Michael Aspengren - MSFT Date: 10/22/2009

My take on @@IDENTITY vs SCOPE_IDENTITY()

This may be considered to be somewhat of a ‘classic’, but as mentioned, many of the entries in this...

Author: Michael Aspengren - MSFT Date: 10/20/2009

DataTable.GetChanges(DataRowState.Modified) returns NULL

The scenario; you have a DataGridView on a Windows Form, you then manually, in code, create a...

Author: Michael Aspengren - MSFT Date: 10/20/2009

XQuery in SQL Server, some examples

I got an XQuery in SQL Server related question from a colleague the other day. I thought I had the...

Author: Michael Aspengren - MSFT Date: 09/21/2009

MemberwiseClone by example

I not ashamed of admitting that I do not know everything about everything J For example, I didn’t...

Author: Michael Aspengren - MSFT Date: 09/17/2009

SGEN gives "Error: The top XML element 'class' from namespace '' references distinct types UserDefinedFunctions.Class and UserDefinedFunctions.Class1."

Another SGEN error that caused me some time to troubleshoot. In this case customer was again calling...

Author: Michael Aspengren - MSFT Date: 09/16/2009

SGEN gives "Assembly ... does not contain any types that can be serialized using XmlSerializer.

The other day I was working a case where a SQL CLR User Defined Function was used. A bit more on...

Author: Michael Aspengren - MSFT Date: 09/15/2009

How to save information about DataSet into the XML when serializing it with WriteXML()

I got a question the other day. How do I serialize my dataset with some descriptive information...

Author: Michael Aspengren - MSFT Date: 09/11/2009

"System.Data.Linq.ChangeConflictException: Row not found or changed" Finding the culprit

When updating a data table in SQL Server using LINQ to SQL and the SubmitChanges() method you may...

Author: Michael Aspengren - MSFT Date: 09/07/2009

Why massive inserts using SubmitChanges lack in performance.

Bulk inserting using LINQ to SQL, why is it so slow? Well, the short answer is that it is not...

Author: Michael Aspengren - MSFT Date: 09/01/2009

How to store performance monitor data into SQL Server using Reliability and Performance Monitor

Exactly what the title says. I spent some time on figuring this out since there is not so much...

Author: Michael Aspengren - MSFT Date: 08/27/2009

How to read a SQL Server trace file using .Net code, TraceFile and TraceServer.

When you wish to trace and see what is going on in SQL Server then the SQL Profiler tool is really...

Author: Michael Aspengren - MSFT Date: 08/27/2009

"There is already an open DataReader associated with this Command which must be closed first" explained

Short one. This sometimes catches people out. When reading a SqlDataReader and then after the read...

Author: Michael Aspengren - MSFT Date: 08/20/2009

IsolationLevel is carried over to connections in connectionpool

When using SqlConnection and Transactions you my get a somewhat unexpected behavior. Namely that...

Author: Michael Aspengren - MSFT Date: 08/17/2009

SQL CLR stored procedure called via JDBC using setAutoCommit(false) does not update database.

I have come across this question a few times; “I have a java client that connects to SQL Server via...

Author: Michael Aspengren - MSFT Date: 07/31/2009

System.Data.SqlClient.SqlException: Cannot open database "database name" requested by the login. The login failed.

A short one today, this is about one of the slightly confusing error messages when it comes to...

Author: Michael Aspengren - MSFT Date: 07/24/2009

Improving XslCompiledTransform performance.

Imagine this scenario, you have some xml files that you wish to transform to html files, this is...

Author: Michael Aspengren - MSFT Date: 07/10/2009

Oracle, Stored Procedures with ref cursor from .Net code and BID tracing.

Ok, many concepts today. First we’ll create some tables, a package and a stored procedure using ref...

Author: Michael Aspengren - MSFT Date: 06/16/2009

How to create a .Net SqlTransaction deadlock with SQL Server

Today I’ll show you an example on how to create DeadLocks with .Net and SQL Server. Normally this is...

Author: Michael Aspengren - MSFT Date: 06/10/2009

How use Convert in a DataTable select?

How to use Convert() when doing DataTable.Select ? Sometimes you may need or want to select out a...

Author: Michael Aspengren - MSFT Date: 05/11/2009

Msg 7399 - The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "" reported an error. Authentication failed.

I’ve seen this one a few times lately. In SQL Server there is a linked server to Access\Excel etc....

Author: Michael Aspengren - MSFT Date: 05/08/2009

A simple example on how to get Return and Out parameter values using Ado.Net

Another short one. How to capture OUT and RETURN parameter values from a stored procedure in .Net....

Author: Michael Aspengren - MSFT Date: 05/07/2009

Using a subset of columns in a datatable as a DataSource for Windows controls.

A short one today. Say that you have a DataTable that is created dynamically or is, for example,...

Author: Michael Aspengren - MSFT Date: 04/22/2009

A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

If you are reading this, you may have searched for this error/exception: A transport-level error has...

Author: Michael Aspengren - MSFT Date: 04/16/2009

Catch a Sql Server RAISERROR at client side using SqlDataReader.

The other day I had a question on using RAISERROR in SQL Server and that it was not propagated down...

Author: Michael Aspengren - MSFT Date: 04/06/2009

Table-Value parameter used in .Net. Simple sample

Table-Value Parameters. One of those new things that I haven’t experimented with. Yet. So, I had a...

Author: Michael Aspengren - MSFT Date: 03/20/2009

Thanks to the brave people showing up for the first public presentation that I’ve done. Hope it was...

Author: Michael Aspengren - MSFT Date: 03/19/2009

Pivot tables in SQL Server. A simple sample.

The other day I was wondering about how to use Pivot tables in SQL Server with SQL, and I didn’t...

Author: Michael Aspengren - MSFT Date: 03/03/2009

DataAdapter.Update returns 0 and doesn't update the table in SQL Server.

Short one today. Sometimes there are reports that the DataAdapter.Update(datatable) method returns 0...

Author: Michael Aspengren - MSFT Date: 03/02/2009

(working) TCP network monitor trace explained.

Today I’ll do something different, I will describe something that works. In this case, how to...

Author: Michael Aspengren - MSFT Date: 02/27/2009

System.InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

This error gets reported every now and then and this is my try to explain what is going on. The...

Author: Michael Aspengren - MSFT Date: 02/27/2009

Getting "Query is too complex" or "Expression is too complex” when using Access

The scenario, you have an MS Access database and you want to run queries against it. A fairly common...

Author: Michael Aspengren - MSFT Date: 02/06/2009

<Previous Next>