Vipul Limbachiya Rotating Header Image

Format your SQL script online and instantly

Hi Friends,

From the last couple of days I’m involved in final fixes and changes in my current project, which is set to release at the end of this week.

While going through few complex stored procedures which are around of more than 800 lines of code I found it clumsy to find out the area I want to change and the code was not at all readable.

The online tool to format SQL from dpriver helps to format your SQL script online and instantly. You can check it out here [http://www.dpriver.com/pp/sqlformat.htm]

Hope it helps you too!.

Happy Coding!

Thanks,
Vipul

VN:F [1.9.3_1094]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Reset identity column’s count

Hi Friends,

This sql command helps to reset (reseed) identity column’s count from the number you wish


DBCC CHECKIDENT (table_name, RESEED, new_reseed_value)

table_name is a name or your desired table and new_reseed_value is a value from which you want your identity pk column’s number to start

Thanks,

Vipul Limbachiya

VN:F [1.9.3_1094]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Free mssql log file space by one command

Hello Friends,

While working with huge data in mssql on and after every query you’ll end up getting popups for low memory space on hard drive as the log generated for this query is as huge as data and the query ran.

I found an interesting command which helps to free the space used in creating those logs:


Backup log [YourDatabaseName] With truncate_only

Go

DBCC ShrinkDatabase ([YourDatabaseName], 10, TruncateOnly)

Go

I’m not sure if it impacts to data restore while dataloss, as this restore could expect log which wiped out using this command, so be sure before using it. But this command surely helps to save space while development.

Wish it helps you too as me :)

Thanks,

Vipul Limbachiya

VN:F [1.9.3_1094]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.3_1094]
Rating: +1 (from 1 vote)

How to handle dynamic form’s submission in CMS :: C# – asp.net

Hi Friends,

I am currently working on maintenance of existing CMS system from our company.

Yesterday client came up with an interesting bug, the dynamic forms generated via CMS has just stopped working

I investigated for more than couple of hours to find out what’s wrong.

In our CMS there is a module of dynamic forms, which generates forms runtime by getting information of forms from an XML file and this form could be added to any page while generating pages from template, and on submission of this form from end users all fields are getting stored in database.

It just posts data to an aspx page, which first identifies for which form this submission has made by looking at hidden field which contains form’s id and then it gets details of this form and then stores all the values to database.

Its not as simple as it looks by this description, it contains form field’s validation by javascript, CAPTCHA validation etc. All this is handled by an aspx page.

Now let come to the problem, the problem was after renewing all templates and frontend, client has introduced asp.net Ajax to all pages and so all pages has an Ajax script manager on page following form tags. The form tag is now on every page as direct child of body tag.

Now when form is generated and rendered to this page there will be 2 forms on page, the main form and this dynamic form which is placed inside main form. So it has to fail anyway :)

So how to solve this??

There is a way, still our form is generated dynamically and does not contain any form fields as server side control we can do this.

There is an option in asp.net to submit a form to different page then the control is placed on(Cross page posting), the option is : PostBackUrl=”~/TargetPage.aspx” this option is available for all controls which are capable to fire server side request/event.

Now how to use this option to the controls that are generated dynamically and are not server controls!!

Yeah, so what I did was:

Created a temp page with this option, I viewed source code to find out how this stuff works, I found an interesting thing:

onclick=’WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(\”btnSubmitToForm\”, \”\”, false, \”\”, \”/TargetPage.aspx\”, false, false));’

This JavaScript makes POST request to mentioned page, I did the same to my form and it works!!!

To make this thing work you would have to set enableViewStateMac=”false” in web.config (or page level should also work!)

So that was good option in asp.net which saved my life!!

Let me know if any problem

-

Vipul Limbachiya

VN:F [1.9.3_1094]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Remove all special characters from a string to make valid xml entry : C#

Hi Friends,

Today I came to a problem while adding an attribute to an XML item in my project. The problem was no special character is allowed as XML attribute

To solve this use this regular expression:

string strNewValue = System.Text.RegularExpressions.Regex.Replace(sourceValue, @”[^\w\.-]“, “”);

It eliminates all special characters from source string, you can specify replace characters as well.

like

string strNewValue = System.Text.RegularExpressions.Regex.Replace(sourceValue, @”[^\w\.-]“, “_”);

will replace all special characters to be “_” (un underscore)

Thanks,

Vipul

VN:F [1.9.3_1094]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Protected: How to create dynamic CMS

This post is password protected. To view it please enter your password below:


VN:F [1.9.3_1094]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)
Pages: Prev 1 2 3 4 5 6 7 8 9 Next