Archive for September, 2007

Use XML in stored procedure

Sometimes it is needed to pass comma separated values to sp and then we extract it. But instead of that we can pass a xml string to sp and convert it to temp table. Here is how :

 

In DAL :

string XMLEntityIDS = “<Root>”;
foreach (int Entity in lstNewEntities)
{
      XMLEntityIDS += “<EntityIDS EntityID=\”" + Entity.ToString() + “\” ></EntityIDS>”;
}
XMLEntityIDS += “</Root>”;
db.AddInParameter(cmdUpdateOrder, “@EntityIDs”, DbType.String, XMLEntityIDS);

 

In SP :

DECLARE @docHandle int    
EXEC sp_xml_preparedocument @docHandle OUTPUT, @EntityIDs 
SELECT * Into #TempEntities FROM OPENXML(@docHandle, N’/Root/EntityIDS’) WITH (EntityID int)

:)

Comments (1)

No More Cell/other gadgets Thief :)

Leave a Comment

.htaccess Editor

We all use .htaccess file for various purposes like URL redirecting, Rewriting the URLs etc. If you do a small mistake in writing rules for this file your entire site becomes unavailable to the visitors and shows 500 Internal server error.

For those of you who don’t know how to edit .htaccess file there is an online tool where you can create code for .htaccess rules for your blog or website.

Editor : http://www.htaccesseditor.com/en.shtml
Source
: http://www.teknobites.com/2007/09/02/htaccess-editor/

Leave a Comment