Category Archives: visual studio 2010

Returning last inserted id in C# using MySql DB provider


As experimenting the integration of MySql database with c# code I came across to a problem that seemed to be a common issue.

Mostly, after executing an INSERT statement you’d like to get back the new ID of the record.
Intuitively, you would think about  creating an output parameter and use  @@IDENTITY or scope_identity() or LAST_INSERT_ID() to assign the value to it.

Unfortunately, it seems that when I use this statement: “SET @newID := @@IDENTITY” I get an exception about sql syntax. Reviewing the exception reveals that somehow it repaced the “@newID” with NULL and therefore not allowing execution. (In my case i used SQL statement and not stored procedure).

As stated here, MySql does not support out parameters in the protocol yet.

All the suggested solutions I found didn’t made this work.

Read the rest of this entry »


Posted by on October 28, 2011 in c#, MySql, SQL, Uncategorized, visual studio 2010


Delegate In Foreach Iteration Bug – Solution


When declaring delegates (anonymous methods) inside of foreach loop, the container only get the last delegate calculated.
The reason is that the foreach loop is designed to reuse declared variables, in our case the delegate is used as a type declared before the loop and reused.

Read the rest of this entry »


Tags: , , , , , ,

Use Popup To Postback/Update It’s Parent/Opener Without losing ViewState Values And Close


Solution for a very common problem about communication between page to popups.
Suitable for every .Net framework especially for .Net 1 .

Read the rest of this entry »


Tags: , , , , ,

JIT (Just In Time) Debugger with Visual Studio .net 2003 and Visual Studio 2010

On my system I got installs of VS2003 and VS2010.  In which VS2003 was installed first.
Trying to catch unhandled exception with vs2003 results in JIT debugger which offers only vs2010.
This article will explain how to solve this prob.

Read the rest of this entry »