Skip to main content

Posts

Showing posts with the label C#

Overriding ConnectionString in Machine.config with web.config ConnectionString.

Overriding ConnectionString in Machine.config with web.config connectionstring. If I have following connectionstring in my machine.config  (Machine level value) <connectionStrings>                  <add name="TestConfigConnection" connectionString="DATA SOURCE=machineCon;PERSIST SECURITY INFO=True;USER ID=usr;PASSWORD=pwd" />  </connectionStrings> Now for specific web application I want a different connection string value then we need to override the value in machine.config. So we  need to add the required connectionstring value in web.config <connectionStrings>                  <add name="TestConfigConnection" connectionString="DATA SOURCE=webCon;PERSIST SECURITY INFO=True;USER ID=usr;PASSWORD=pwd" />  </connectionStrings> But with this, it ...

Why can't we have send and receive within an atomic scope

Why can't we have send and receive within an atomic scope? The atomic scope was designed to handle Atomicity, Consistency, Isolation, and Durability (ACID) compliant operations that must either all succeed or all fail as a group. This is a classic database transaction style. It is designed to carry an orchestration from one stable state to another. This is why you cannot both send and receive from an atomic scope, because by design the message box is not a lockable resource . To accomplish this atomicity, the orchestration engine persists the entire orchestration state to the message box before the atomic scope begins; it subsequently persists the orchestration again when the atomic scope completes.

ASP.NET Clear the GridView data on specific condition

ASP.NET Clear the GridView data on specific condition When there are no data found for user search criteria then we want to clear the previous gridview data and display "No record found" message to user. This can be achieved by following line of code: Set the DataSource = null and bind this to your gridview. if (lblError.Visible == false )                 {                     if (dvCustomerRecords.Count > 0)                     {                         gvCustomer.DataSource = dvCustomerRecords;                ...

C# : check whether input string data is XML or NOT

To check whether input string data is XML or NOT. Simply copy and paste the following code. This code will throw an exception in case input string is not XML.        if (! String .IsNullOrEmpty(sXMLMessage))             {                 try                 {                     System.Xml.Linq. XElement .Parse(sXMLMessage);                    // Business Logic for XML string data here                 }            ...