Posts

Showing posts from 2009

Fix error "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance."

I also suffered from this several time and solved following the article in below link. Hope it'll help you all also. Regards,

Ajax Calender Extender

http://www.asp.net/learn/ajax-videos/video-124.aspx

ExcellentASP NETCodes

http://www.scribd.com/doc/2946769/ExcellentASP-NETCodes

Using Stored Procedures in Conjuction with DataAdapter

sqlCmd = new SqlCommand(); sqlCmd.Connection = conn; sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandText = "get_wf"; SqlDataAdapter adapter = new SqlDataAdapter(); conn.Open(); adapter.SelectCommand = sqlCmd; adapter.Fill(dataTable);

DataSet vs DataView

using dataview we can just create the view of the table and perform any updations or deletions it wont be affected on the database table. whare as dataset is used for disconnected architecture and we can store any number of tables in the dataset form different data sources using data adapters

Reading Connection Strings in Web.Config and App.Config and Enterprise Library DAAB Settings

Reading All Connection Strings in App.Config or Web.Config Actually, reading all the connection strings in the app.config or web.config is pretty easy now that we have the wonderful System.Configuration Namespace and its rich functionality. The code is pretty straight forward. We can read all the connection strings as well as each name, provider, etc: ConnectionStringSettingsCollection connectionStrings = ConfigurationManager.ConnectionStrings; foreach (ConnectionStringSettings connection in connectionStrings) { string connectionStringName = connection.Name; string connectionString = connection.ConnectionString; string providerName = connection.ProviderName; Debug.Print(connectionStringName); } reference : http://www.davidhayden.com/blog/dave/archive/2007/02/22/ReadConnectionStringsWebConfigAppConfig.aspx

How to read from web.config?

You have to import System.Configuration Lets say you have this in your web.config file: [appSettings] [add key="keyName" value="keyValue" /] [/appSettings] Retrieve it like this using System.Configuration; ConfigurationSettings.AppSettings["keyName"];

Singleton pattern implementation in C#

using System; public sealed class Singleton { private static volatile Singleton instance; private static object syncRoot = new Object(); private Singleton() {} public static Singleton Instance { get { if (instance == null) { lock (syncRoot) { if (instance == null) instance = new Singleton(); } } return instance; } } } This approach ensures that only one instance is created and only when the instance is needed. Also, the variable is declared to be volatile to ensure that assignment to the instance variable completes before the instance variable can be accessed. Lastly, this approach uses a syncRoot instance to lock on, rather than locking on the type itself, to avoid deadlocks. This double-check locking approach solves the thread concurrency problems while avoiding an exclusive lock in every call to the Instance property method. It also allows you ...
What is the difference between Session and Cookies... As far as my knowledge is concerned, cookies are stored on client side where as sessions are server variables. The storage limitations are also there (like IE restricts the size of cookie to be not more than 4096 bytes). We can store only a string value in a cookie where as objects can be stored in session variables. The client will have to accept the cookies in order to use cookies, there is no need of user's approval or confirmation to use Session variables cos they are stored on server. The other aspect of this issue is cookies can be stored as long as we want(even for life time) if the user accepts them, but with session variables we can only store something in it as long as the session is not timed out or the browser window is not closed which ever occurs first. Coming to usage you can use both cookies and session in the same page. We should go for cookies to store something that we want to know when the user returns to ...