tag:blogger.com,1999:blog-83716185397754957712024-03-12T20:21:47.125-07:00Asp.net question answersAsp.net question answers, sql server question answersAmit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-8371618539775495771.post-39028046361876200112010-03-15T23:22:00.000-07:002010-03-15T23:24:06.536-07:00BACKUP LOG [db name] WITH TRUNCATE_ONLYBACKUP LOG [DB name] WITH TRUNCATE_ONLY in sql sever, when transaction log is full.Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-35542661847910509892010-01-29T11:16:00.000-08:002010-01-29T11:19:43.692-08:00Singleton Design Pattern in Asp.net using C#<span style="font-weight:bold;">Singleton Design Pattern in Asp.net using C#</span><br /><br/><br /><span style="font-weight:bold;">Introduction</span><br /><br />When we want to make a only one instance of a class and also making sure that there is a global access point to that object then the design pattern we user is called Singleton. The pattern ensures that the class is instantiated only once and that all requests are directed to that one and only object.<br />Usage<br /><br />In asp.net you can use singleton through sessions or application variables easily however i will show you how to implement singleton object to User class.<br />Problem<br /><br />In Asp.net to get user information like first name, surname or username through Memebership object does not look neat because to get UserID first you need to know user User.Identity.Name then use Membership.GetUser in order to get more detail for user.<br />Solution<br /><br />I have created a interface called IUser which you can use anywhere on the page.<br /><br />public interface IUser<br /><br /> {<br /><br /> string Email { get; set; }<br /><br /> string Firstname { get; set; }<br /><br /> string Surname { get; set; }<br /><br /> string UserID { get; set; }<br /><br /> string Username { get; set; }<br /><br /> }<br /><br />Here is our Singleton class implementing IUser.<br /><br />public sealed class Singleton<br /><br /> {<br /><br /> private const string IUserSessionName = "User";<br /><br /> private static IUser objUser = new UserClass();<br /><br /> Singleton()<br /><br /> {<br /><br /> <br /><br /> }<br /><br /> /// <summary><br /><br /> /// Loading user information<br /><br /> /// </summary><br /><br /> public static IUser IUserInstance<br /><br /> {<br /><br /> get<br /><br /> {<br /><br /> if (null == Session[IUserSessionName])<br /><br /> {<br /><br /> if (User.Identity.IsAuthenticated)<br /><br /> {<br /><br /> string userID = Membership.GetUser().ProviderUserKey.ToString();<br /><br /> // getting userinformation from database<br /><br /> objUser = new UserClass().GetUserInformation(userID);<br /><br /> Session[IUserSessionName] = objUser;<br /><br /> }<br /><br /> }<br /><br /> else<br /><br /> {<br /><br /> objUser = (IUser)Current.Session[IUserSessionName];<br /><br /> }<br /><br /> <br /><br /> return objUser;<br /><br /> }<br /><br /> set<br /><br /> {<br /><br /> Session[IUserSessionName] = value;<br /><br /> }<br /><br /> }<br /><br /> <br /><br /> public static void UserInstanceFlush()<br /><br /> {<br /><br /> Session[IUserSessionName] = null;<br /><br /> }<br /><br /> <br /><br /> }<br /><br />Because of IuserSessionName you are also making sure that you will keep this session name unique and at only one place.<br /><br />IUser is a static property which can be used on any page from Singleton.IUserInstance.UserID.<br /><br />UserInstanceFlush flushes the session if you want to remove the session value.Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-70696641020696564002009-12-23T11:05:00.000-08:002010-01-07T08:12:50.955-08:00syntax to send mail in as forwardhref="mailto:?subject=Check%20out%20this%20link...&body=You%20are%20invited%20to%20check%20out%20a%20cool%20site:%20%20http%3A%2F%2Fwww.mysite.com">Mail Link to a Friend - forward <br /><br /><br /><a href="mailto:?subject=Check%20out%20this%20link...&body=You%20are%20invited%20to%20check%20out%20a%20cool%20site:%20%20http%3A%2F%2Fwww.mysite.com">Mail Link to a Friend</a>Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-24101981888391706202009-07-18T05:33:00.000-07:002009-07-18T05:35:29.191-07:00how to select top 2 max record in sql serverwrite the query for find the top 2 highest salary in sql server<br /><br />select esalary from emp_sal e where 2>=(select count(distinct esalary) <br />from emp_sal where e.esalary<=esalary)Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-17274636868453065282009-06-24T05:19:00.000-07:002009-07-17T23:59:40.307-07:00Dynamic controls in asp.net, Adding a dynamic control to a placeholder control and wire up the event in ASP.netASP.NET provides a dedicated control the PlaceHolder control. You can place this control somewhere on your webform and later on use it to hang dynamic controls.<br /><br />Now i am describing step by step how i generate and use LinkButton Dynamically.<br />Refer below code to generate Linkbutton at runtime.<br /><br />Step 1-First take placeholder on your webform <br /><br />Step 2-write this code on server side in c#<br /><br /><br />protected override void OnInit(EventArgs e)<br />{<br /> for(int i=0;i<5;i++)<br /> {<br /><br /> LinkButton LinkToEditPage = new LinkButton();<br /><br /> LinkToEditPage.Text = "Name" + i.ToString();<br /> //Add new LinkButton to placeholder<br /> PlaceHolder1.Controls.Add(LinkToEditPage); <br /> LinkToEditPage.Attributes.Add("IdUser", "LinkButton" + i.ToString());<br /> // Wire up the eventhandler<br /> LinkToEditPage.Click += new EventHandler(LinkToEditPage_Click);<br /> }<br />}<br /><br /><br />//its Event handler code below<br /><br /> protected void LinkToEditPage_Click(object sender, EventArgs e)<br /> {<br /> // Get the control and cast it to the<br /> // appropriate type. In our case a LinkButton.<br /><br /> LinkButton LB = (LinkButton)sender;<br /> string IdUser = LB.Attributes["IdUser"];<br /><br /> Response.Write("You Click on " + IdUser);<br /><br /> }<br /><br />Step 3-see the output:<br /><br />when you will run this webform, output will be show like refer below.<br /> <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_TbJ-QgnEfXE/SkIonL2FQAI/AAAAAAAAAEU/f0ZZvzFMjBQ/s1600-h/linkbutton.jpg"><img style="cursor:pointer; cursor:hand;width: 257px; height: 74px;" src="http://2.bp.blogspot.com/_TbJ-QgnEfXE/SkIonL2FQAI/AAAAAAAAAEU/f0ZZvzFMjBQ/s320/linkbutton.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5350883960929206274" /></a><br /><br />when you click on any of one output message will come accordingly.<br />suppose you have click on secod linkButton output will come as <br /><span style="font-weight:bold;">"You Click on LinkButton2"<span style="font-style:italic;"></span></span><br /><br />I hope this example can give you the idea how to generate dynamic control in asp.net and handle their event.Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-38226764500561554922009-06-23T10:33:00.000-07:002009-06-23T10:37:14.828-07:00ASP.NET MVC for Visual Studio 2010 AvailableMicrosoft continues to provide solutions orbiting around its next-generation development platform and tools, well after the first public release of Visual Studio 2010 was launched in mid-May, 2009. The latest addition to the list of items designed to expand Visual Studio 2010 is ASP.NET MVC. The web framework tailored specifically for the first beta of Visual Studio 2010 is currently live on Microsoft's open-source project repository<br />website CodePlex, and is available for download. The company indicated that the bits were in Alpha stage for the time being. <a href="http://news.softpedia.com/news/Download-ASP-NET-MVC-for-Visual-Studio-2010-Beta-1-114483.shtml">View More Information Here </a>Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-64220238806590340192009-06-20T13:13:00.000-07:002009-06-20T13:37:25.577-07:00what is Hibernate Interview Questions<span style="font-weight:bold;"> What is Hibernate?</span><br /><br />Hibernate is an object-relational mapping (ORM) solution for the language.<br />it provides an easy to use framework for mapping an object-oriented domain model to a traditional relational database.Hibernate is a powerful, high performance object/relational persistence and query service. This lets the users to develop persistent classes following object-oriented principles such as association, inheritance, polymorphism, composition, and collections.<br /><br /><span style="font-weight:bold;"> What is NHibernate?</span><br />NHibernate is an Object-relational mapping (ORM) solution for the Microsoft .NET platform. to know more about <a href="https://www.hibernate.org/343.html">click here to know NHibernate</a><a href="https://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/"hibernate.org></a><br /><br /><span style="font-weight:bold;"> What is ORM?</span><br /><br />ORM stands for Object/Relational mapping. It is the programmed and translucent perseverance of objects in a Java application in to the tables of a relational database using the metadata that describes the mapping between the objects and the database. It works by transforming the data from one representation to another.<br /><br /><span style="font-weight:bold;">What are the benefits of ORM and Hibernate?</span><br /><br />There are many benefits from these. Out of which the following are the most important one.<br /><br /> 1. Productivity – Hibernate reduces the burden of developer by providing much of the functionality and let the developer to concentrate on business logic.<br /> 2. Maintainability – As hibernate provides most of the functionality, the LOC for the application will be reduced and it is easy to maintain. By automated object/relational persistence it even reduces the LOC.<br /> 3. Performance – Hand-coded persistence provided greater performance than automated one. But this is not true all the times. But in hibernate, it provides more optimization that works all the time there by increasing the performance. If it is automated persistence then it still increases the performance.<br /> 4. Vendor independence – Irrespective of the different types of databases that are there, hibernate provides a much easier way to develop a cross platform application.Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-46510342422989681172009-06-19T04:46:00.001-07:002009-06-19T04:46:29.061-07:005 Basic Tips Of Web Hosting<a href=http://shar.es/qHz8>5 Basic Tips Of Web Hosting</a><br /><br />Posted using <a href="http://sharethis.com">ShareThis</a>Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-34013329844718341922009-06-18T00:05:00.000-07:002009-06-25T01:52:16.592-07:00sql query using substring function in sqlserverLets take a example suppose there is table - "tbl_emp"<br />contain column like tbl_emp(first_name,Last_name,"column3","column4",...)<br /><br />suppose one row contain data like this:<br /><br /><span style="font-weight:bold;">First_name, last _name , "column3","column4",...<br />amit , pathak ,'..',''</span><br /><br />now in result if you want name will show as Apathak in place of amit pathak<br />we can use this Query using substring function of sqlserver<br /><br /><span style="font-weight:bold;"><br />SELECT UPPER(SUBSTRING(FIRST_NAME,1,1)) + '' + LAST_NAME AS NAME FROM TBL_EMP <br /><br />Result: Apathak</span><br /><br />DETAIL OF SUBSTRING FUNCTION BELOW:<br />SUBSTRING ( STRING,START POSITION,NO OF CHARACTERS REQUIRED POSITION)<br /><br /><span style="font-weight:bold;">I more expale of SUBSTRING with CHARINDEX function</span><br /><br />I have seen a problem of one person detail below.<br /><br />i have string like 1017 , 9 , 10-06-2009 , 1|'5001','FORMAN S COMMISSION ','9','2','0','0',10-06-2009,1|'5002','DEFAULT INTEREST (CHITTY)','9','2','0','0',10-06-2009,1<br /><br />i want to remove first part i.e 1017 , 9 , 10-06-2009 , 1<br />and i want to use rest part of the string.... <br /><br /><span style="font-style:italic;">Solution:<span style="font-weight:bold;"></span></span><br /><br />use substring function with charindex you will get string what you desire.......<br />i have seen problem there is "|" char find common in every column so on that behalf i have split the string and provide the need full result.<br /><br />select substring('1017 , 9 , 10-06-2009 , 1|5001,FORMAN S COMMISSION', charindex( '|','1017 , 9 , 10-06-2009 , 1|5001,FORMAN S COMMISSION')+1, len('1017 , 9 , 10-06-2009 , 1|5001,FORMAN S COMMISSION')) from tbl_emp<br /><br /><br /><br />DETAIL OF CHARINDEX FUNCTION BELOW:<br />SUBSTRING ( Pattern match,STRING) <br />result will be position of pattern where it matches.<br />Exp: SUBSTRING ( "M","AMIT Pathak") result will 2 because M is found on 2nd position in string "AMIT Pathak".Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com2tag:blogger.com,1999:blog-8371618539775495771.post-2587998631556307262009-06-10T05:47:00.000-07:002009-06-10T06:09:55.987-07:00how to insert data from one table to another table in sql serverEvery DBA needs to transfer data between tables. <br />lets we have create a table that has the following structure,<br /><br />create table tbl_product_Information(<br />product_name char(50),<br />price float,<br />EntryDate datetime<br />)<br /><br /><br />and now we wish to insert one additional row into the table of the product data.<br /><br />We will hence use the following SQL script:<br /><br />INSERT INTO tbl_product_Information(product_name, price,Entry Date)<br />VALUES ('ABC', 900, 'Jan-10-1999')<br /><br />Above is the very simple insert command.<br /><br />The second type of INSERT INTO allows us to insert multiple rows into a table. Unlike the previous example, where we insert a single row by <br /><br />specifying its values for all columns, we now use a SELECT statement to specify the data that we want to insert into the table. If you are thinking <br /><br />whether this means that you are using information from another table, you are correct. The syntax is as follows:<br /><br />INSERT INTO "table1" ("column1", "column2", ...)<br />SELECT "column3", "column4", ...<br />FROM "table2"<br /><br /><br />So this is the way you can insert data from one table to another table in sql server.Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com1tag:blogger.com,1999:blog-8371618539775495771.post-65244429217554563172009-06-02T05:22:00.000-07:002009-06-10T06:10:40.570-07:00No value given for one or more required parameters - soultion : insert values into database using vb.netHow to Insert values into msaccess database using oledb and find the solution of error <span style="font-weight:bold;">"No value given for one or more required parameters"</span> : <br /><br />Dim myOleDbConnection As OleDb.OleDbConnection<br /> Dim insert As String<br /> Dim value1, value2, value3, value4 As String<br /><br /> value1 = "'" & "ContactID" & "'" ' So to avoid the error("No value given for one or more required parameters") use ' single qoutes before and end of coulumn value<br /> value2 = "'" & "FirstName" & "'"<br /> value3 = "'" & "LastName" & "'"<br /> value4 = "'" & "Sent" & "'"<br /><br /> Try<br /><br /> <br /> Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _<br /> & "Data Source=C:\Documents and Settings\Administrator\Desktop\schoolapp\SchoolApp\school.mdb;"<br /> '"Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source = C:\Users\Edward\Desktop\db1.mdb;"<br /><br /> insert = "INSERT INTO Cancelled (ContactID, FirstName, LastName, Sent) VALUES (" & value1 & " ," & value2 & " ," & value3 & " ," & value4 & ")"<br /><br /><br /><br /> myOleDbConnection = New OleDb.OleDbConnection(myConnectionString)<br /> myOleDbConnection.Open()<br /> Dim myOleDbCommand As New OleDb.OleDbCommand(insert, myOleDbConnection)<br /><br /> myOleDbCommand = myOleDbConnection.CreateCommand<br /><br /> myOleDbCommand.CommandType = CommandType.Text<br /><br /> myOleDbCommand.CommandText = insert<br /><br /> myOleDbCommand.ExecuteNonQuery()<br /><br /> myOleDbConnection.Close()<br /><br /> Catch ex As Exception<br /> Trace.WriteLine(ex.ToString)<br /> End Try<br /> <br /><br /> '-------Correct Query--------<br /> ' when you trace the value of insert will be : INSERT INTO Cancelled (ContactID, FirstName, LastName, Sent) VALUES ('ContactID' ,'FirstName' ,'LastName' ,'Sent')<br /><br /> '------Wrong Query-------<br /> ' basically the problem ("No value given for one or more required parameters") accurs when insert query will be :<br /> ' INSERT INTO Cancelled (ContactID, FirstName, LastName, Sent) VALUES (ContactID ,FirstName ,LastName ,Sent)<br /> ' because here inserted values doesn't have ' single quotes before and end of coulmn value which is mandatory while inserting data.<br /><br /> End SubAmit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-52617014641649429002009-06-02T04:17:00.000-07:002009-06-10T06:11:39.980-07:00Free vb.net to c sharp and c sharp to vb.net code converter free onlineYou can find Free vb.net to c sharp and c sharp to vb.net code converter free online<br />vist this site <a href="http://www.developerfusion.com/tools/convert/vb-to-csharp/" >Free vb.net to c# code converter</a>Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-42542703285188402832009-05-29T04:40:00.000-07:002009-05-29T05:22:27.792-07:00How to read xml file in asp.net<span style="font-size:85%;"><span style="font-family: arial;"> This Article will see how we can read and XML file it our ASP.NET application using vb.net, this trick is use full for making custom configuration files for your application or just reading data stored in an xml file.</span><br /><br /><span style="font-family: arial;">Here is an XML save as name "countries.xml":</span><br /><br /><span style="font-family: arial;"><br />-------Create xml file follow image below----------------------------</span><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_TbJ-QgnEfXE/Sh_TX4gwORI/AAAAAAAAABY/OYkhVa4F_RM/s1600-h/CropperCapture%5B34%5D.jpg"><img style="cursor:pointer; cursor:hand;width: 231px; height: 320px;" src="http://1.bp.blogspot.com/_TbJ-QgnEfXE/Sh_TX4gwORI/AAAAAAAAABY/OYkhVa4F_RM/s320/CropperCapture%5B34%5D.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5341220090344913170" target="_blank" /></a><br /><br />-------End of xml File-----------------------------------------------------------</span><br /><br /><span style="font-family: arial;"><br /><br />---------Code Snap-shot-------------</span><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_TbJ-QgnEfXE/Sh_Riy_yemI/AAAAAAAAABQ/yIFBUIBFGuQ/s1600-h/CropperCapture%5B33%5D.jpg"><img style="cursor:pointer; cursor:hand;width: 320px; height: 318px;" src="http://3.bp.blogspot.com/_TbJ-QgnEfXE/Sh_Riy_yemI/AAAAAAAAABQ/yIFBUIBFGuQ/s320/CropperCapture%5B33%5D.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5341218078819777122" /></a><br /><br /><br /><br /><span style="font-weight: bold; font-family: arial;"><span style="font-style: italic;">Out Put</span>: Radiobuttonlist will generate like displayed below </span><span style="font-style: italic; font-weight: bold; font-family: arial;">:</span><br /><br /></span><table style="width: 147px; height: 94px; font-family: arial;" id="rb" border="0"> <tbody> <tr> <td><span style="font-size:85%;"><input id="rb_0" onclick="javascript:setTimeout('__doPostBack(\'rb$0\',\'\')', 0)" value="N" name="rb" type="radio">India</span></td><td style="vertical-align: top;"><span style="font-size:85%;"><br /></span></td><td style="vertical-align: top; text-align: justify;"><span style="font-size:85%;"><br /></span></td></tr> <tr> <td><span style="font-size:85%;"><input id="rb_1" onclick="javascript:setTimeout('__doPostBack(\'rb$1\',\'\')', 0)" value="S" name="rb" type="radio">America</span></td><td style="vertical-align: top;"><span style="font-size:85%;"><br /></span></td><td style="vertical-align: top;"><span style="font-size:85%;"><br /></span></td></tr> <tr> <td><span style="font-size:85%;"><input id="rb_2" onclick="javascript:setTimeout('__doPostBack(\'rb$2\',\'\')', 0)" value="F" name="rb" type="radio"><label for="rb_2">France</label></span></td><td style="vertical-align: top;"><span style="font-size:85%;"><br /></span></td><td style="vertical-align: top;"><span style="font-size:85%;"><br /></span></td></tr> <tr> <td><span style="font-size:85%;"><input id="rb_3" onclick="javascript:setTimeout('__doPostBack(\'rb$3\',\'\')', 0)" value="I" name="rb" type="radio">Spain</span></td><td style="vertical-align: top;"><span style="font-size:85%;"><br /></span></td><td style="vertical-align: top;"><span style="font-size:85%;"><br /></span></td></tr></tbody></table> <p style="font-family: arial;"><span style="font-size:85%;"><span id="lbl1"></span></span></p> <div style="font-family: arial;"><input id="__EVENTVALIDATION" value="/wEWBgKs4IKVCQKsgIgBAqOAiAEClICIAQKpgIgBAs7vou8MqXXV59fnec8g6nEs3TvbaFQnk6A=" name="__EVENTVALIDATION" type="hidden"> <span style="font-size:85%;"><br /></span></div><span style="font-size:85%;"><br /><br /><br /></span>Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-23022910745533602762009-05-29T04:00:00.000-07:002009-05-29T04:18:49.717-07:00New Features in ASP.NET 3.5<h2 style="font-family:arial;"><span style="font-size:85%;">ASP.NET AJAX</span></h2> <p style="font-family:arial;"><span style="font-size:85%;">With ASP.NET AJAX, developers can quickly create pages with sophisticated, responsive user interfaces and more efficient client-server communication by simply adding a few server controls to their pages. Previously an extension to the ASP.NET <span class="blsp-spelling-error" id="SPELLING_ERROR_0">runtime</span>, ASP.NET AJAX is now built into the platform and makes the complicated task of building cross-platform, standards based AJAX applications easy.<br /></span></p><p style="font-family:arial;"> </p><p style="font-family: arial;" class="more bumptopmore"><span></span></p> <h2 style="font-family:arial;">New <span class="blsp-spelling-error" id="SPELLING_ERROR_1">ListView</span> and <span class="blsp-spelling-error" id="SPELLING_ERROR_2">DataPager</span> Controls</h2> <p style="font-family:arial;"><span style="font-size:85%;">The new <span class="blsp-spelling-error" id="SPELLING_ERROR_3">ListView</span> control gives you unprecedented flexibility in how you display your data, by allowing you to have complete control over the HTML markup generated. <span class="blsp-spelling-error" id="SPELLING_ERROR_4">ListView</span>‘s template approach to representing data is designed to easily work with <span class="blsp-spelling-error" id="SPELLING_ERROR_5">CSS</span> styles, which comes in handy with the new Visual Studio 2008 designer view. In addition, you can use the <span class="blsp-spelling-error" id="SPELLING_ERROR_6">DataPager</span> control to handle all the work of allowing your users to page through large numbers of records</span>.<br /></p><p face="arial"> </p><p style="font-family: arial;" class="more bumptopmore"><span></span></p> <h2 style="font-family:arial;"><span class="blsp-spelling-error" id="SPELLING_ERROR_7">LINQ</span> and other .NET Framework 3.5 Improvements</h2> <p face="arial"><span style="font-size:85%;">With the addition of Language Integrated Query (<span class="blsp-spelling-error" id="SPELLING_ERROR_8">LINQ</span>) in .NET Framework 3.5, the process of building <span class="blsp-spelling-error" id="SPELLING_ERROR_9">SQL</span> queries using error-prone string manipulation is a thing of the past. <span class="blsp-spelling-error" id="SPELLING_ERROR_10">LINQ</span> makes your relational data queries a first-class language construct in C# and Visual Basic, complete with compiler and <span class="blsp-spelling-error" id="SPELLING_ERROR_11">Intellisense</span> support. For Web applications, the ASP.NET <span class="blsp-spelling-error" id="SPELLING_ERROR_12">LinqDataSource</span> control allows you to easily use <span class="blsp-spelling-error" id="SPELLING_ERROR_13">LINQ</span> to filter, order and group data that can then be bound to any of the data visualization controls like the <span class="blsp-spelling-error" id="SPELLING_ERROR_14">ListView</span> and <span class="blsp-spelling-error" id="SPELLING_ERROR_15">GridView</span> controls. In addition, all the other improvements to .NET Framework 3.5, including the new <span class="blsp-spelling-error" id="SPELLING_ERROR_16">HashSet</span> collection, <span class="blsp-spelling-error" id="SPELLING_ERROR_17">DateTime</span> offset support, diagnostics, garbage collection, better thread lock support, and more, are all available to you in your ASP.NET applications. </span><br /></p><p face="arial"><br /></p><p face="arial"> </p><p style="font-family: arial;" class="more bumptopmore"><span></span></p> <h2 style="font-family:arial;"><span class="blsp-spelling-error" id="SPELLING_ERROR_18">WCF</span> Support for <span class="blsp-spelling-error" id="SPELLING_ERROR_19">RSS</span>, <span class="blsp-spelling-error" id="SPELLING_ERROR_20">JSON</span>, POX and Partial Trust</h2> <p style="font-family: arial;"><span style="font-size:85%;"><span style="font-size:85%;">With .NET Framework 3.5, Windows Communication Foundation (<span class="blsp-spelling-error" id="SPELLING_ERROR_21">WCF</span>) now supports building Web services that can be exposed using any number of the Internet standard protocols, such as SOAP, <span class="blsp-spelling-error" id="SPELLING_ERROR_22">RSS</span>, <span class="blsp-spelling-error" id="SPELLING_ERROR_23">JSON</span>, POX and more. Whether you are building an AJAX application that uses <span class="blsp-spelling-error" id="SPELLING_ERROR_24">JSON</span>, providing syndication of your data via <span class="blsp-spelling-error" id="SPELLING_ERROR_25">RSS</span>, or building a standard SOAP Web service, <span class="blsp-spelling-error" id="SPELLING_ERROR_26">WCF</span> makes it easy to create your endpoints, and now, with .NET Framework 3.5, supports building Web services in partial-trust situations like a typical shared-hosting environment</span>. </span><br /></p><p style="font-family: arial;"><br /></p><p style="font-weight: bold; color: rgb(153, 0, 0);font-family:arial;"><span style="font-size:180%;">New Web Features in Visual Studio 2008</span></p><h2 style="font-family: arial;">New Web Design Interface</h2> <p style="font-family: arial;"><span style="font-size:85%;">Visual Studio 2008 has incorporated a new Web designer that uses the design engine from Expression Web. Moving between design and source view is faster than ever and the new split view capability means you can edit the HTML source and simultaneously see the results on the page. Support for style sheets in separate files has been added as well as a CSS properties pane which clarifies the sometimes-complex hierarchy of cascading styles, so that it is easy to understand why an element looks the way it does. In addition Visual Studio 2008 has full WYSIWYG support for building and using ASP.NET Nested Master Pages which greatly improves the ability to build a Web site with a consistent look and feel. </span><br /></p><p style="font-family: arial;"> </p><p style="font-family: arial;" class="more bumptopmore"><span></span></p> <h2 style="font-family: arial;">JavaScript Debugging and Intellisense</h2> <p style="font-family: arial;"><span style="font-size:85%;">In Visual Studio 2008, client-side JavaScript has now become a first-class citizen in regards to its debugging and Intellisense support. Not only does the Intellisense give standard JavaScript keyword support, but it will automatically infer variable types and provide method, property and event support from any number of included script files. Similarly, the JavaScript debugging support now allows for the deep Watch and Locals support in JavaScript that you are accustomed to having in other languages in Visual Studio. And despite the dynamic nature of a lot of JavaScript, you will always be able to visualize and step into the JavaScript code, no matter where it is generated from. This is especially convenient when building ASP.NET AJAX applications. </span><br /></p><p style="font-family: arial;"> </p><p style="font-family: arial;" class="more bumptopmore"><span></span></p> <h2 style="font-family: arial;">Multi-targeting Support</h2> <p style="font-family: arial;"><span style="font-size:85%;">In previous versions of Visual Studio, you could only build projects that targeted a single version of the .NET Framework. With Visual Studio 2008, we have introduced the concept of Multi-targeting. Through a simple drop-down, you can decide if you want a project to target .NET Framework 2.0, 3.0 or 3.5. The builds, the Intellisense, the toolbox, etc. will all adjust to the feature set of the specific version of the .NET Framework which you choose. This allows you to take advantage of the new features in Visual Studio 2008, like the Web design interface, and the improved JavaScript support, and still build your projects for their current runtime version. </span></p>Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com0tag:blogger.com,1999:blog-8371618539775495771.post-46638127793560181362009-05-29T00:37:00.000-07:002009-05-29T01:39:30.472-07:00Asp.net c# interview questions and answers<h1 class="entry-title">C# interview questions and answers</h1> <div class="entry-meta"><span class="author vcard"></span><span class="entry-date"><abbr class="published" title="2003-12-07T22:48:55-0600"><br /></abbr></span></div><!-- .entry-meta --> <ol style="margin-top: 0in;" start="1" type="1"><li class="MsoNormal" style=""><b>What’s the advantage of using System.Text.StringBuilder over System.String? </b>StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.</li><p><span id="more-57"></span> </p><li class="MsoNormal" style=""><b>Can you store multiple data types in System.Array? </b>No.</li><li class="MsoNormal" style=""><b>What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? </b>The first one performs a deep copy of the array, the second one is shallow.</li><li class="MsoNormal" style=""><b>How can you sort the elements of the array in descending order? </b>By calling Sort() and then Reverse() methods.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s the .NET datatype that allows the retrieval of data by a unique key? </b>HashTable.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s class SortedList underneath? </b>A sorted HashTable.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Will <i>finally</i> block get executed if the exception had not occurred? </b>Yes.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? </b>A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Can multiple catch blocks be executed? </b>No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Why is it a bad idea to throw your own exceptions? </b>Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s a delegate? </b>A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s a multicast delegate? </b>It’s a delegate that points to and eventually fires off several methods.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>How’s the DLL Hell problem solved in .NET? </b>Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What are the ways to deploy an assembly? </b>An MSI installer, a CAB archive, and XCOPY command.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s a satellite assembly? </b>When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What namespaces are necessary to create a localized application? </b>System.Globalization, System.Resources.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s the difference between // comments, /* */ comments and /// comments? </b>Single-line, multi-line and XML documentation comments.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>How do you generate documentation from the C# file commented properly with a command-line compiler? </b>Compile it with a /doc switch.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s the difference between <c> and <code> XML documentation tag? </code></c></b>Single line code example and multiple-line code example.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Is XML case-sensitive? </b>Yes, so <student> and <student> are different elements.<b><o p=""></o></b></student></student></li><li class="MsoNormal" style=""><b>What debugging tools come with the .NET SDK? </b>CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What does the This window show in the debugger? </b>It points to the object that’s pointed to by this reference. Object’s instance data is shown.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What does assert() do? </b>In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s the difference between the Debug class and Trace class? Documentation looks the same. </b>Use Debug class for debug builds, use Trace class for both debug and release builds.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Why are there five tracing levels in System.Diagnostics.TraceSwitcher? </b>The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Where is the output of TextWriterTraceListener redirected? </b>To the Console or a text file depending on the parameter passed to the constructor.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>How do you debug an ASP.NET Web application? </b>Attach the aspnet_wp.exe process to the DbgClr debugger.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What are three test cases you should go through in unit testing? </b>Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Can you change the value of a variable while debugging a C# application? </b>Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Explain the three services model (three-tier application). </b>Presentation (UI), business (logic and underlying code) and data (from storage or other sources).<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? </b>SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s the role of the DataReader class in ADO.NET connections? </b>It returns a read-only dataset from the data source when the command is executed.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all employees whose name starts with La. </b>The wildcard character is %, the proper query with LIKE would involve ‘La%’.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Explain ACID rule of thumb for transactions. </b>Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What connections does Microsoft SQL Server support? </b>Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Which one is trusted and which one is untrusted? </b>Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>Why would you use untrusted verificaion? </b>Web Services might use it, as well as non-Windows applications.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What does the parameter Initial Catalog define inside Connection String? </b>The database name to connect to.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What’s the data provider name to connect to Access database? </b>Microsoft.Access.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What does Dispose method do with the connection object? </b>Deletes it from the memory.<b><o p=""></o></b></li><li class="MsoNormal" style=""><b>What is a pre-requisite for connection pooling? </b>Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.</li></ol>Amit pathakhttp://www.blogger.com/profile/02082758282914726879noreply@blogger.com1