<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2273979700509904477</id><updated>2012-02-16T02:53:42.320-08:00</updated><category term='Dot Net'/><category term='Sql Server'/><title type='text'>Robin's Technical blogs</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://rttechno.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://rttechno.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Robin Thomas</name><uri>http://www.blogger.com/profile/06325464726038153377</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2273979700509904477.post-8556777004480504929</id><published>2009-02-08T06:14:00.000-08:00</published><updated>2009-02-08T08:50:48.515-08:00</updated><title type='text'>Connecting Csharp application and SQL Server 2005</title><content type='html'>This blog is for beginners who is seeing Visual Studio 2008 for the first time. This is a very basic tutorial.&lt;div&gt;           Here is a step by step explanation on how to connect SQL server database with C#. I think there is no nee&lt;/div&gt;&lt;div&gt;d for much explanation since the images are self explanatory.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Our aim is to create a very simple C# application which save an employee name and an employee email ID into  SQL server database.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Create DB to store Values &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 1 : Open Sql Server Management Studio Express and Create a Database called Employee&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_09BMu_-9NxY/SY7yJ9EWsJI/AAAAAAAAAAk/9zxfwvnKHPw/s1600-h/Create+DB4.JPG"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_09BMu_-9NxY/SY7yJ9EWsJI/AAAAAAAAAAk/9zxfwvnKHPw/s1600-h/Create+DB4.JPG"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;If you don't have Sql Server Management Studio Express ,  click &lt;a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796&amp;amp;displaylang=en"&gt;here &lt;/a&gt;to download it&lt;/div&gt;&lt;img src="http://3.bp.blogspot.com/_09BMu_-9NxY/SY7x5MYKIYI/AAAAAAAAAAM/ESbGPj0z7Kw/s320/Create+DB1.JPG" style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 305px; height: 256px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5300439776339042690" /&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 2 : Create a table "tbl_Employee" and create two columns to store Name and Email ID&lt;img src="http://4.bp.blogspot.com/_09BMu_-9NxY/SY7z6MvvhEI/AAAAAAAAAAs/XoeZf4MCWlE/s400/Create+DB3.JPG" style="cursor:pointer; cursor:hand;width: 286px; height: 316px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5300441992641086530" /&gt;&lt;img src="http://4.bp.blogspot.com/_09BMu_-9NxY/SY7z6CfnrzI/AAAAAAAAAA0/AjdV-nIkRCY/s400/Create+DB4.JPG" style="cursor:pointer; cursor:hand;width: 400px; height: 167px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5300441989889109810" /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Create a C# application&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 1 : Open  Microsoft Visual Studio 2008 and create a new Project&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step2 : In the Default.aspx Page Create an interface to enter values &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt; It should include the following : &lt;/div&gt;&lt;div&gt;                 1 Text box to enter Name (txtName)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt; 2. Text box to enter Email ID (txtEmail)&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt; 3. A button to save the data.(btnSave)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="http://3.bp.blogspot.com/_09BMu_-9NxY/SY8B8zhaqaI/AAAAAAAAABU/tW0W2rhD5jg/s400/Emp+Screen.JPG" style="cursor:pointer; cursor:hand;width: 400px; height: 128px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5300457430572509602" /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 3 : Specify the connection string value in web.config. Open your web.config file . Search for the following tag $ltconnectionstrings&gt; . &lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;connectionstrings&gt;&lt;/connectionstrings&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255); white-space: pre; "&gt;  &lt;&lt;span class="Apple-style-span" style="font-style: italic; "&gt;connectionStrings&gt;   &lt;add name="connString" connectionstring="server=YourServerName;database=Employee;Integrated Security=SSPI; "&gt;  &lt;/add&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&lt;connectionstrings&gt;&lt;/connectionstrings&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;connectionstrings&gt;Edit the connectionStrings settings as follows&lt;/connectionstrings&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&amp;lt;connectionStrings&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&amp;lt;add name="connString" connectionString="server=COMP\SQLEXPRESS;database=Employee;Integrated Security=SSPI; "/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;&amp;lt;/connectionStrings&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you are not sure about your server name , Open Microsoft Sql Server Management Studio Express and check the  server name. See the image below.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;img src="http://2.bp.blogspot.com/_09BMu_-9NxY/SY75bccQJqI/AAAAAAAAABE/z1eneH8kBp0/s400/Server+Name.JPG" style="cursor:pointer; cursor:hand;width: 304px; height: 304px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5300448061348128418" /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 4 : Write the code to save the Value to DB in Click event of the Save button.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;protected void btnSave_Click(object sender, EventArgs e) &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;{&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; string connectionString = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;          &lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;SqlConnection cnn = new SqlConnection();&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; cnn.ConnectionString = connectionString;          &lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;SqlCommand sqlCommand = new SqlCommand();         &lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;sqlCommand.Connection = cnn;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; cnn.Open();          &lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;try         {&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; sqlCommand.CommandText = "INSERT INTO tbl_Employee ([Name],[EmailID]) VALUES " +                                       "('" + txtName.Text + "','" + txtEmail.Text + "')";&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; sqlCommand.ExecuteNonQuery();&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; lblStatusMessage.Text = "Data inserted successfully";&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; }&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; catch (Exception ex)         &lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;{&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; Response.Write("An error occurred while inserting values to DB&lt;br /&gt;" + ex.ToString());&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; }         &lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt;finally         {&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; if (cnn.State == ConnectionState.Open)                 cnn.Close();&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; }&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 102, 255);"&gt; }&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;Now you are ready to go.. Run the application.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2273979700509904477-8556777004480504929?l=rttechno.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rttechno.blogspot.com/feeds/8556777004480504929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rttechno.blogspot.com/2009/02/connecting-c-application-and-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/8556777004480504929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/8556777004480504929'/><link rel='alternate' type='text/html' href='http://rttechno.blogspot.com/2009/02/connecting-c-application-and-sql-server.html' title='Connecting Csharp application and SQL Server 2005'/><author><name>Robin Thomas</name><uri>http://www.blogger.com/profile/06325464726038153377</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_09BMu_-9NxY/SY7x5MYKIYI/AAAAAAAAAAM/ESbGPj0z7Kw/s72-c/Create+DB1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2273979700509904477.post-3378428389843786495</id><published>2009-01-12T07:37:00.000-08:00</published><updated>2009-01-12T07:46:59.975-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server'/><title type='text'>Paging in MS SQL server. (An alternative to Limit in MySQL)</title><content type='html'>&lt;div&gt;&lt;div&gt;&lt;div&gt;  If you are a .NET developer , then you might know the paging capabilities of ASP.NET data &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;controls like Gridview. But the main problem associated with this paging is that , each time a &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;new page is requested all the records are transferred from the data server. If the data server &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;and your application is in different physical locations, then it causes a performance dropdown.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;So it will be always better if we can do the paging in SQL server. In &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;MySQL&lt;/span&gt; this is &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;straight forward and needs no complex queries.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;SELECT * FROM tablename ORDER BY key LIMIT 10 OFFSET 100 .. simple.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But in MS SQL the keyword Limits or its alternative is not available.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So we need to find our own solution for this.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;LIMIT in MSSQL - solution using ROW_NUMBER()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;ROW_NUMBER()  &lt;/span&gt;&lt;/span&gt;Returns the sequential number of a row in a result set, starting at 1 for the first &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;row.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; Let's consider an example.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Suppose you have a table.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;CREATE TABLE [dbo].[JobDetails](&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[ControlID] [int] NOT NULL,&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[JobDescription] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[Priority] [int] NULL,&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[CreatedOn] [datetime] NULL,&lt;/div&gt;&lt;div&gt; CONSTRAINT [PK_JobDetails] PRIMARY KEY CLUSTERED &lt;/div&gt;&lt;div&gt;(&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;[ControlID] ASC&lt;/div&gt;&lt;div&gt;)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]&lt;/div&gt;&lt;div&gt;) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And records..&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;ALTER TABLE dbo.JobDetails NOCHECK CONSTRAINT ALL&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-- Insert new records&lt;/div&gt;&lt;div&gt;INSERT INTO dbo.JobDetails ([ControlID], [CreatedOn], [JobDescription], [Priority]) VALUES (1, &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;'2008-10-10 00:00:00', 'Job Description 1', 10)&lt;/div&gt;&lt;div&gt;INSERT INTO dbo.JobDetails ([ControlID], [CreatedOn], [JobDescription], [Priority]) VALUES (2, &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;'2008-11-10 00:00:00', 'Job Description 2', 10)&lt;/div&gt;&lt;div&gt;INSERT INTO dbo.JobDetails ([ControlID], [CreatedOn], [JobDescription], [Priority]) VALUES (3, &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;'2008-10-10 00:00:00', 'Job Description 3', 11)&lt;/div&gt;&lt;div&gt;INSERT INTO dbo.JobDetails ([ControlID], [CreatedOn], [JobDescription], [Priority]) VALUES (4, &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;'2008-10-10 00:00:00', 'Job Description 4', 12)&lt;/div&gt;&lt;div&gt;INSERT INTO dbo.JobDetails ([ControlID], [CreatedOn], [JobDescription], [Priority]) VALUES (5, &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;'2008-10-10 00:00:00', 'Job Description 5', 9)&lt;/div&gt;&lt;div&gt;-- Enable all check on table&lt;/div&gt;&lt;div&gt;ALTER TABLE dbo.JobDetails CHECK CONSTRAINT ALL&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now , I need to include paging for this records. I have to get the job order by Priority and &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;CreatedOn Date. So here is the code to do that.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;DECLARE @PageNumber int&lt;/div&gt;&lt;div&gt;SET @PageNumber = 1&lt;/div&gt;&lt;div&gt;DECLARE @PageSize int&lt;/div&gt;&lt;div&gt;SET @PageSize = 3&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;SELECT *&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;FROM&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;(SELECT ROW_NUMBER() OVER(ORDER BY Priority asc , CreatedOn desc ) AS &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;sequenceNum,&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;*&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;FROM JobDetails &lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;-- WHERE ...(you can include where condition here if u need)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;)temp&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;WHERE temp.sequenceNum BETWEEN ((@PageNumber-1)*@PageSize)+1 AND (@PageNumber * &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;@PageSize)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hope this will be useful for you. If you want to see a live implementation of this query, you &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;can see the following page in a job site. Click here to view &lt;a href="http://www.fresherscenter.com/jobs.aspx"&gt;demo&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2273979700509904477-3378428389843786495?l=rttechno.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rttechno.blogspot.com/feeds/3378428389843786495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rttechno.blogspot.com/2009/01/paging-in-ms-sql-server-alternative-to.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/3378428389843786495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/3378428389843786495'/><link rel='alternate' type='text/html' href='http://rttechno.blogspot.com/2009/01/paging-in-ms-sql-server-alternative-to.html' title='Paging in MS SQL server. (An alternative to Limit in MySQL)'/><author><name>Robin Thomas</name><uri>http://www.blogger.com/profile/06325464726038153377</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2273979700509904477.post-7502963928063941990</id><published>2009-01-03T09:46:00.000-08:00</published><updated>2009-01-12T07:56:11.767-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server'/><title type='text'>Updating Only Non NULL parameters in Stored Procedure</title><content type='html'>All the developers who worked on SQL server surely will have encountered the following situation atleast once.&lt;br /&gt;"Update only the columns with non null values in parameter in a row."&lt;br /&gt;I will explain this.&lt;br /&gt;Suppose you have a users table. You are using a single stored procedure to update all the columns in table.&lt;br /&gt;suppose now you need to change only the field 'Name' using this stored procedure. The other parameters will be empty. Then u can use the ISNULL property to update the table.&lt;br /&gt;Here is an example.&lt;br /&gt;CREATE PROC [dbo].[usp_UserDetailsUpdate]&lt;br /&gt;@ControlID int,&lt;br /&gt;@EmailId varchar(255)=NULL,&lt;br /&gt; @LoginId varchar(255)=NULL,&lt;br /&gt; @Name varchar(255)=NULL&lt;br /&gt;AS&lt;br /&gt;UPDATE [dbo].[UserDetails]&lt;br /&gt;SET&lt;br /&gt; [EmailId] = ISNULL(@EmailId, EmailId),&lt;br /&gt;[LoginId] = ISNULL(@LoginId,LoginId),&lt;br /&gt;[Name] = ISNULL(@Name, [Name]&lt;br /&gt;WHERE [ControlID] = @ControlID&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2273979700509904477-7502963928063941990?l=rttechno.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rttechno.blogspot.com/feeds/7502963928063941990/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rttechno.blogspot.com/2009/01/updating-only-non-null-parameters-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/7502963928063941990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/7502963928063941990'/><link rel='alternate' type='text/html' href='http://rttechno.blogspot.com/2009/01/updating-only-non-null-parameters-in.html' title='Updating Only Non NULL parameters in Stored Procedure'/><author><name>Robin Thomas</name><uri>http://www.blogger.com/profile/06325464726038153377</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2273979700509904477.post-54641020628865468</id><published>2009-01-03T09:16:00.000-08:00</published><updated>2009-01-12T07:56:30.714-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Dot Net'/><title type='text'>StringBuilder Vs String Concatenations</title><content type='html'>&lt;p class="MsoNormal" style="MARGIN-BOTTOM: 12pt; LINE-HEIGHT: normal"&gt;StringBuilder or String Concatenation.. Which is better ?&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How they work ?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;String is immutable while StringBuilder is mutable.&lt;br /&gt;After a string object is created its value cannot be changed. Then how&lt;br /&gt;name ="jimmy"+"augustine" is possible ? When we assign this , we actually discard the old string object and create a new string.&lt;br /&gt;&lt;br /&gt;But StringBuilder is mutable. StringBuilder class provides methods to change its contents at anytime.StringBuilder has a very useful method "append" to add new strings to the end of the existing string. StringBuilder internally reserves a certain amount of memory(Buffer). When a new string is added to the StringBuilder, the new string is just copied to the existing buffer. If the buffer is not enough to fit the new string , then a new buffer is created to fit the new string.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;My Performance Test ( StringBuilder VS Concatenation):&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Here is a simple performance test which demonstrate the power of stringBuilder over string concatenation.&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal"&gt;&lt;span style="COLOR: rgb(0,0,153)"&gt;DateTime start;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,0,153)"&gt;start = DateTime.Now;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,0,153)"&gt;StringBuilder strBuilder = new StringBuilder();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,0,153)"&gt;for (int i = 0; i &lt; strbuilderexecutiontime =" DateTime.Now" builder ="" start =" DateTime.Now;" str =" string.Empty;"&gt;&lt;/span&gt;&lt;span style="COLOR: rgb(0,0,153)"&gt;for (int i = 0; i &lt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,0,153)"&gt;{&lt;br /&gt;str = str + i;&lt;br /&gt;}&lt;br /&gt;strBuilderExecutionTime =DateTime.Now - start ;&lt;br /&gt;Console.WriteLine("Exection Time for Concatenation =" + strBuilderExecutionTime.ToString());&lt;/span&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;span style="LINE-HEIGHT: 115%"&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Output :&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,0,153)"&gt;Execution Time for string builder =00:00:00.0312500&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(0,0,153)"&gt;Execution Time for Concatenation =00:01:18.5937500&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When looking at the output of the code , it is very clear that StringBuilder is much more efficient than the regular concatenation.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Is there any disadvantage for StringBuilder when comparing with String concatenation ?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Is StringBuilder always a better Option than concatenation ? No... Because creating a StringBuilder object using the constructor will take time. So if there is only few concatenations ( say less than 5 apprx) , then no need to go for StringBuilder.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Conclusion:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If the number of concatenations is more , then use StringBuilder. But if the number of concatenations is very few then go for ordinary "+" concatenations.&lt;br /&gt;If the number of concatenations is more than 8, then in all the situations StringBuilder is faster than String concatenations.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2273979700509904477-54641020628865468?l=rttechno.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rttechno.blogspot.com/feeds/54641020628865468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rttechno.blogspot.com/2009/01/stringbuilder-vs-string-concatenations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/54641020628865468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/54641020628865468'/><link rel='alternate' type='text/html' href='http://rttechno.blogspot.com/2009/01/stringbuilder-vs-string-concatenations.html' title='StringBuilder Vs String Concatenations'/><author><name>Robin Thomas</name><uri>http://www.blogger.com/profile/06325464726038153377</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2273979700509904477.post-7871609783739457783</id><published>2009-01-03T09:09:00.000-08:00</published><updated>2009-01-12T07:56:30.714-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Dot Net'/><title type='text'>Web Config file in ASP.net</title><content type='html'>&lt;p class="MsoNormal" style="COLOR: rgb(192,192,192)"&gt;&lt;b&gt;&lt;span style="COLOR: rgb(0,0,102)"&gt;How to add a web.config file?&lt;/span&gt;&lt;?xml:namespace prefix = o /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p style="COLOR: rgb(192,192,192)"&gt;&lt;/o:p&gt;&lt;br /&gt;1) Create a new website by selecting &lt;span style="font-size:+0;"&gt;&lt;/span&gt;File-&gt;New-&gt;Website from the Menu&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;Visual Studio 2005 will create a basic website with a default page for you.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;2) Click on the Website -&gt;Add New Item from the menu or press Ctrl+Shift+A&lt;/p&gt;&lt;p class="MsoNormal"&gt;A new pop up window will be displayed. Select Web Configuration File from the popUp.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_gi9FftIXdTc/R9uoNLCuI8I/AAAAAAAAAAM/769P2i9Tmfs/s1600-h/Add+a+new+web+config.GIF"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;3) Now you can see a Web.config file added to your project.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;The default web.config file will look something like this.(I removed all the comments from web.config)&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;configuration&gt;&lt;/configuration&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;appsettings&gt;&lt;/appsettings&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;connectionstrings&gt;&lt;/connectionstrings&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;system.web&gt;&lt;/SYSTEM.WEB&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;compilation debug="true"&gt;&lt;/compilation&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;authentication mode="Windows"&gt;&lt;/authentication&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;We can now use the web.config file. Now lets store a value in web.config file and read that from our application.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="COLOR: rgb(0,0,102)"&gt;Reading a value from web.config.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;1) Open web.config file&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;2) Add a new key in web.config file under AppSettings.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;appsettings&gt;&lt;/appsettings&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;add value="SampleName" key="Name"&gt;&lt;/add&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;Now the web.config file will look like this.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;configuration&gt;&lt;/configuration&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;appsettings&gt;&lt;/appsettings&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;add value="SampleName" key="Name"&gt;&lt;/add&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;connectionstrings&gt;&lt;/connectionstrings&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;system.web&gt;&lt;/SYSTEM.WEB&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;compilation debug="true"&gt;&lt;/compilation&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;authentication mode="Windows"&gt;&lt;/authentication&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;3) Now We can read this value from our aspx page.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;For reading a value from web.config file, we can use the ConfigurationManager class.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;Write the following code in page load event .&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;String Name = ConfigurationManager.AppSettings.Get("Name");&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;Response.Write("Value of Name from web.config is : " + Name);&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;4) Now run your sample website. &lt;span style="font-size:+0;"&gt;&lt;/span&gt;Done !&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="COLOR: rgb(0,0,102)"&gt;Storing a Connection String in web.config.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;Storing your connection string in web.config file when you are using visual studion 2005 is very easy.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;You can add a new connection string under the tag &lt;connectionstrings&gt;&lt;/connectionstrings&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;Here is a sample web.config.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;connectionstrings&gt;&lt;/connectionstrings&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;add connectionstring="Data Source=ROBIN-0C2A48868\\SQLEXPRESS;Initial Catalog=TestDB;Integrated Security=True;Pooling=False" name="TestConnectionString"&gt;&lt;/add&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:+0;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;You can read the connection string using the following code.&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;String connectionString = ConfigurationManager.ConnectionStrings["TestConnectionString"].ToString();&lt;/p&gt;&lt;p class="MsoNormal"&gt;Response.Write("Value of TestConnectionString from web.config is : " + connectionString);&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2273979700509904477-7871609783739457783?l=rttechno.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rttechno.blogspot.com/feeds/7871609783739457783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://rttechno.blogspot.com/2009/01/web-config-file-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/7871609783739457783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2273979700509904477/posts/default/7871609783739457783'/><link rel='alternate' type='text/html' href='http://rttechno.blogspot.com/2009/01/web-config-file-in-aspnet.html' title='Web Config file in ASP.net'/><author><name>Robin Thomas</name><uri>http://www.blogger.com/profile/06325464726038153377</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
