Best View in Google Crome, Mozilla firefox or IE 7 or above
Friday, December 25, 2015
Saturday, October 11, 2014
Good books on ADO.Net
I frequently get emails asking suggestion on good books on ADO.Net.
Here are few good books on ADO.Net for your reference.
1. Microsoft ADO.NET 4 Step by Step (Step by Step (Microsoft))
2. Murach's ADO.NET 4 Database Programming with C# 2010
(Murach: Training & Reference)
3. ADO.NET 3.5 Cookbook (Cookbooks (O'Reilly))
4. A Programmer's Guide to ADO.NET in C sharp (Expert's Voice)
Here are few good books on ADO.Net for your reference.
1. Microsoft ADO.NET 4 Step by Step (Step by Step (Microsoft))
2. Murach's ADO.NET 4 Database Programming with C# 2010
(Murach: Training & Reference)
3. ADO.NET 3.5 Cookbook (Cookbooks (O'Reilly))
4. A Programmer's Guide to ADO.NET in C sharp (Expert's Voice)
Labels:
ADO.Net,
ASP.Net,
Dotnet Books,
Dotnet Interview Question
Sunday, April 6, 2014
Difference between constructor and method in c#
This is a very basic question mainly asked in Beginner level interviews (1 to 2 years of experience).
The interviewer can twist the question as below as well.
Answer:
Here are few differences between Constructor and methods in bullet points.
Constructor:
1. Name of constructor should be same as class name
2. Constructor is used to initialize class members (variables). It is used to create an instance of a class.
3. Returns nothing. Hence no return type.
4. Called implicitly at the time of object creation
Method:
1. Name is independent from class name
2. Method is having some functionality. It is used to perform some operations.
3. Must return something. If nothing to return, explicitly return type should be void.
4. Need to be called explicitly
The interviewer can twist the question as below as well.
- Difference between method and constructor in c#
- Difference between constructor and method in dotnet with example
- Difference between methods and constructors in object oriented programming
Answer:
Here are few differences between Constructor and methods in bullet points.
Constructor:
1. Name of constructor should be same as class name
2. Constructor is used to initialize class members (variables). It is used to create an instance of a class.
3. Returns nothing. Hence no return type.
4. Called implicitly at the time of object creation
Method:
1. Name is independent from class name
2. Method is having some functionality. It is used to perform some operations.
3. Must return something. If nothing to return, explicitly return type should be void.
4. Need to be called explicitly
Tuesday, February 12, 2013
What are the commonly used classes in System.Data.SqlClient?
Here are the commonly used classes in System.Data.SqlClient:
SqlCommand:
Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database.
SqlCommandBuilder:
Automatically generates single-table commands used to reconcile changes made to a DataSet with the associated SQL Server database.
SqlConnection:
Represents an open connection to a SQL Server database.
SqlDataAdapter:
Represents a set of data commands and a database connection that are used to fill the DataSet and update a SQL Server database.
SqlDataReader:
Provides a means of reading a forward-only stream of rows from a SQL Server database.
SqlTransaction:
Represents a Transact-SQL transaction to be made in a SQL Server database.
For more ADO.Net Interview Questions, click here.
Labels:
ADO.Net,
Dotnet Basics,
Dotnet Interview Question
What is the Namespace for using SQL Server database in Dotnet Application?
System.Data.SqlClient namespace is the .NET Framework Data Provider for SQL Server.
The .NET Framework Data Provider for SQL Server describes a collection of classes used to access a SQL Server database in the managed space. Using the SqlDataAdapter, you can fill a memory-resident DataSet, which you can use to query and update the database.
For the commonly used classes in System.Data.SqlClient, click here.
For more ADO.Net Interview Questions, click here.
The .NET Framework Data Provider for SQL Server describes a collection of classes used to access a SQL Server database in the managed space. Using the SqlDataAdapter, you can fill a memory-resident DataSet, which you can use to query and update the database.
For the commonly used classes in System.Data.SqlClient, click here.
For more ADO.Net Interview Questions, click here.
Saturday, February 2, 2013
What is QueryString? What are the advantages and disadvantages of QueryString?
QueryString is a property of Request object in ASP.Net that provides a mechanism to send information to the server in the form of Sting in the URL.
Example: http://www.testsite.com/Webform1.aspx?fname=Alok&lname=Ranjan
In the above example, the destination webform name is Webform1.aspx and the information passed in QueryString is fname=Alok&lname=Ranjan. fname is a variable whose value is Alok, and similarly lname variable has value as Ranjan.
Advantages of QueryString:
Disadvantages of QueryString:
Example: http://www.testsite.com/Webform1.aspx?fname=Alok&lname=Ranjan
In the above example, the destination webform name is Webform1.aspx and the information passed in QueryString is fname=Alok&lname=Ranjan. fname is a variable whose value is Alok, and similarly lname variable has value as Ranjan.
Advantages of QueryString:
- It's very easy to implement
- Every browser works with QueryString.
- It doesn't require server resources. Hence, doesn't put any burden on Server.
Disadvantages of QueryString:
- There is a limitation in the length of the QueryString as URL length has a limit. If you have to send lot of information, QueryString approach doesn't work.
- The information passed through QueryString is publicly visible. Hence, it poses security issue. So, QueryString can't be used while sending sensitive info.
- QueryString can not be used to send & and space characters.
Labels:
ASP.Net,
Interview Questions,
QueryString
Thursday, January 12, 2012
Leap Year Calculator and JavaScript Source Code
By Definition, "A leap year is a year containing one extra day in order to keep the calendar year synchronized with the astronomical or seasonal year."
In a Leap Year, February month has 29 days.
If you are looking for the Algorithm or Source Code to find leap year, here it is.
if year modulo 4 is 0
then
if year modulo 100 is 0
then
if year modulo 400 is 0
then
is_leap_year
else
not_leap_year
else is_leap_year
else not_leap_year
Enter the year you wish to check
function LeapYear()
{
x =0;
x= document.getElementById("txtin").value;
if(x=="")
{
document.getElementById("txtout").value="Year can't be blank";
}
else if(isNaN(x))
{
document.getElementById("txtout").value="Enter a valid Year";
}
else
{
if(x%4==0)
{
if(x%100==0)
{
if(x%400==0)
document.getElementById("txtout").value="Leap Year";
else
document.getElementById("txtout").value="Not Leap Year";
}
else
document.getElementById("txtout").value="Leap Year";
}
else
document.getElementById("txtout").value="Not Leap Year";
}
}
</script>
Enter the year you wish to check
<input id="txtin" type="text" /><button onclick="LeapYear()" type="button">Check Leap Year</button>
<input id="txtout" size="40/" type="text" />
You can use the same logic and create your own calculator in C# or VB.Net or any other Programming Language.
Let me know if you face any difficulties in implementing your own calculator.
In a Leap Year, February month has 29 days.
If you are looking for the Algorithm or Source Code to find leap year, here it is.
Leap Year Algorithm:
Here is the Pseudo code to determine whether a year is a leap year or not.if year modulo 4 is 0
then
if year modulo 100 is 0
then
if year modulo 400 is 0
then
is_leap_year
else
not_leap_year
else is_leap_year
else not_leap_year
Leap Year Calculator:
Enter the year you wish to check
Leap Year Calculator Source Code in JavaScript:
<script type="text/javascript">function LeapYear()
{
x =0;
x= document.getElementById("txtin").value;
if(x=="")
{
document.getElementById("txtout").value="Year can't be blank";
}
else if(isNaN(x))
{
document.getElementById("txtout").value="Enter a valid Year";
}
else
{
if(x%4==0)
{
if(x%100==0)
{
if(x%400==0)
document.getElementById("txtout").value="Leap Year";
else
document.getElementById("txtout").value="Not Leap Year";
}
else
document.getElementById("txtout").value="Leap Year";
}
else
document.getElementById("txtout").value="Not Leap Year";
}
}
</script>
Enter the year you wish to check
<input id="txtin" type="text" /><button onclick="LeapYear()" type="button">Check Leap Year</button>
<input id="txtout" size="40/" type="text" />
You can use the same logic and create your own calculator in C# or VB.Net or any other Programming Language.
Let me know if you face any difficulties in implementing your own calculator.
Monday, December 26, 2011
How to Learn Dotnet Basics?
This article is intended for Students, freshers or experienced professionals who want to learn dotnet as beginners.
Here are some useful websites to get started:
http://www.asp.net/web-forms/tutorials
http://www.asp.net/web-forms/videos
http://www.dotnetspider.com/tutorials
http://www.w3schools.com
http://asp.net-tutorials.com
http://www.csharp-station.com/Tutorial/
There are many more useful websites on Dotnet tutorials. If you come across a good website, do share in comments.
Microsoft Press books
Wrox Publication
Classroom training in Dotnet:
To get started and familiarize with Dotnet Tools and Techniques , a classroom training in dotnet is very helpful. You can learn many things in a short span of time. So, enroll yourself in a good Dotnet training programme.Online tutorials:
There are many useful websites that guides you with Dotnet step by step tutorials, examples etc. There are also a lot of dotnet videos tutorials available in the internet.Here are some useful websites to get started:
http://www.asp.net/web-forms/tutorials
http://www.asp.net/web-forms/videos
http://www.dotnetspider.com/tutorials
http://www.w3schools.com
http://asp.net-tutorials.com
http://www.csharp-station.com/Tutorial/
There are many more useful websites on Dotnet tutorials. If you come across a good website, do share in comments.
Books:
.Net Programming Black BookMicrosoft Press books
Wrox Publication
Sunday, July 24, 2011
Dotnet Interview Questions for 1 year experience
Here are few basic dotnet interview questions asked in interview for a 1 year experience candidate.
Then follows technical discussion.
2. How memory is managed in Dotnet applications?
Hint: Automatically by Garbage collector
3. What is an assembly?
4. What is a strong name?
5. What is MSIL?
2. What is a Class? What is an Object?
3. What is a partial class?
4. What is a sealed class?
5. What is constructor?
6. What is stringbuilder?
2. What is Datareader?
3. Difference between Dataset and datareader?
4. What is Ado.Net?
5. Namespace for using sqlserver database?
2. What is global.asax?
3. What is session?
4. Which all controls you have used in your project?
5. What is gridview?
6. What is Authentication in ASP.Net and types of authentication?
2. What is index? Types of index?
3. What is a stored procedure? Why it is better than inline query?
Hint: Stored Procedure is precompiles and has a execution plan. Hence faster execution.
4. You might be asked to write simple query
5. What is inner join
Also, if you know any advance concepts like WCF, WPF, LINQ, MVC, JQuerymention while telling "about yourself". You will be given preference. But, make sure you know the basics or worked on them for sometime.
Post questions you faced in interview in comments. Also post answers in comments to questions mentioned above.
About your project:
Get maximum knowledge about your current project. You should know the architecture diagram of your project. Also, you have to explain the Dataflow. You might be asked to tell what all dotnet new features used in your project.Then follows technical discussion.
Dotnet Framework Interview Questions for 1 Year Experience:
1. What is CLR and it's functions?2. How memory is managed in Dotnet applications?
Hint: Automatically by Garbage collector
3. What is an assembly?
4. What is a strong name?
5. What is MSIL?
C# Interview Questions for 1 Year Experience:
1. What are the 4 pillars of Object Oriented Programming?2. What is a Class? What is an Object?
3. What is a partial class?
4. What is a sealed class?
5. What is constructor?
6. What is stringbuilder?
ADO.Net Interview Questions for 1 Year Experience:
1. What is connection string?2. What is Datareader?
3. Difference between Dataset and datareader?
4. What is Ado.Net?
5. Namespace for using sqlserver database?
ASP.Net Interview Questions for 1 Year Experience:
1. What is web.config file and it's use?2. What is global.asax?
3. What is session?
4. Which all controls you have used in your project?
5. What is gridview?
6. What is Authentication in ASP.Net and types of authentication?
SQL Server Interview Questions for 1 Year Experience:
1. What is Primary key, unique key and difference between them?2. What is index? Types of index?
3. What is a stored procedure? Why it is better than inline query?
Hint: Stored Procedure is precompiles and has a execution plan. Hence faster execution.
4. You might be asked to write simple query
5. What is inner join
Also, if you know any advance concepts like WCF, WPF, LINQ, MVC, JQuerymention while telling "about yourself". You will be given preference. But, make sure you know the basics or worked on them for sometime.
Post questions you faced in interview in comments. Also post answers in comments to questions mentioned above.
Monday, July 11, 2011
What is the difference between web.config and machine.config
Web.config and machine.config are two files used for managing configuration of web applications.
Machine.config:
1. The configurations mentioned in machine.config file are applicable to all the applications hosted in a machine/computer/server.2. The machine.config file is located in x:\
3. There can be only one machine.config file per machine (per dotnet framework installed).
web.config:
1. web.config file contains configurations for a single application.2. Web.config files overrides the configurations mentioned in machine.config file.
3. The web configuration file is located in your application's root folder
4. There can be multiple web.config files in a single web application in different sub folders.
Labels:
ASP.Net,
Interview Questions,
machine.config,
web.config
Sunday, July 10, 2011
Difference between a temp table and Table Variable in SQL Server
Here are the main differences:
1. Declaration syntax:
Temp Table: CREATE TABLE #tmptbl(ID INT, NAME VARCHAR(20))Table Variable: DECLARE @tblvar TABLE(ID INT, NAME VARCHAR(20))
2. Creating Index:
You can create Indexes (Clustered and non-clustered Indexes) in Temp Tables. This can return records faster if there are large number of records in a table.You cannot create indexes in Table Variables.
Note: You can have Primary key in table variables which will create a clustered index by default. But you cannot create any index explicitly by using Create Index command.
3. Transaction:
The transaction logs are not recorded for the table-variables. Hence, we cannot implement transaction mechanism in case of table variables.But transaction mechanism is applicable in case of temp tables.
CREATE TABLE #tmptbl (val VARCHAR(50))
DECLARE @tblvar TABLE(val VARCHAR(50))
INSERT INTO #tmptbl VALUES ('Old value in temp table')
INSERT INTO @tblvar VALUES ('Old value in table variable')
BEGIN TRAN
UPDATE #tmptbl SET val='New value in temp table'
UPDATE @tblvar SET val='New value in table variable'
SELECT * FROM #tmptbl
SELECT * FROM @tblvar
ROLLBACK
SELECT * FROM #tmptbl
SELECT * FROM @tblvar
The output will be as below:
New value in temp table
New value in table variable
Old value in temp table
New value in table variable
Notice that the Update command against the table variable is not getting rolled back.
4. Stored Procedure Recompilation:
A procedure with a temporary table cannot be pre-compiled. But a procedure with table-variables can be compiled in advance. A Pre-compiled Stored Procedure runs faster.5. Performance:
For small to medium volumes of data and simple usage scenarios you should use table variables. For large set of data, you should go for Temp tables (with proper Indexes).If you have any more differences, please share in comments.
Labels:
SQL Server,
table variable,
Temp table
Sunday, June 26, 2011
Find the Bugs in this C Sharp Dotnet Code
Here is another simple C Sharp dotnet interview question.
There is a piece of code in C# Dotnet as written below. The function takes a number array as input and returns the largest number. It has few bugs in it. Find out the bugs and fix them.
{
int max = int.MaxValue;
for (int i = 0; i < list.Length - 1; i++)
if (list[i] > max)
max = list[i];
return max;
}
You can post the answers as comments. Thank you.
There is a piece of code in C# Dotnet as written below. The function takes a number array as input and returns the largest number. It has few bugs in it. Find out the bugs and fix them.
Code :
public static int Largest(int[] list){
int max = int.MaxValue;
for (int i = 0; i < list.Length - 1; i++)
if (list[i] > max)
max = list[i];
return max;
}
You can post the answers as comments. Thank you.
Labels:
bugs,
C sharp code,
c sharp interview questions
String Reverse with X in between each character in C Sharp Dotnet
Here is a C# Interview question I faced in an interview. This is very easy. But, I am sharing just to make all of you aware of this type of questions being asked in interviews.
public static string xReverse(string inputStr)
{
int len = inputStr.Length;
StringBuilder revStr = new StringBuilder();
for (int i = len - 1; i >= 0; i--)
{
revStr.Append(inputStr[i]);
if (i != 0)
{
revStr.Append('X');
}
}
return revStr.ToString();
}
If anybody has any other solution or has a better idea, please share as comments.
Question:
Write a function named XReverse in C# that will take a string as input and return the reverse of the string with 'X' in between each characters as Output.Solution Code:
public static string xReverse(string inputStr)
{
int len = inputStr.Length;
StringBuilder revStr = new StringBuilder();
for (int i = len - 1; i >= 0; i--)
{
revStr.Append(inputStr[i]);
if (i != 0)
{
revStr.Append('X');
}
}
return revStr.ToString();
}
Output:
If anybody has any other solution or has a better idea, please share as comments.
Labels:
C sharp code,
String Reverse,
xreverse
Wednesday, March 30, 2011
Interview Question on Inheritance and Default Constructor
Here is a question on OOPS concepts like Inheritance and Default Constructor. The code provided is in C#.
There are three classes named A, B and C.
Class A has a default constructor that writes "In A" to console. Similarly Class B and C has default constructors that write "In B", and "In C" to Console respectively.
Class C inherits from Class B and Class B inherits from class A.
[Code]
class A
{
public A()
{
Console.WriteLine("In A");
}
}
class B:A
{
public B()
{
Console.WriteLine("In B");
}
}
class C:B
{
public C()
{
Console.WriteLine("In C");
}
}
[/Code]
Now, the question is as below.
If we instanciate class C, what will be the output.
[Code]
static void Main(string[] args)
{
C objC = new C();
Console.Read();
}
[/Code]
Result:
The result will be:
In A
In B
In C
There are three classes named A, B and C.
Class A has a default constructor that writes "In A" to console. Similarly Class B and C has default constructors that write "In B", and "In C" to Console respectively.
Class C inherits from Class B and Class B inherits from class A.
[Code]
class A
{
public A()
{
Console.WriteLine("In A");
}
}
class B:A
{
public B()
{
Console.WriteLine("In B");
}
}
class C:B
{
public C()
{
Console.WriteLine("In C");
}
}
[/Code]
Now, the question is as below.
If we instanciate class C, what will be the output.
[Code]
static void Main(string[] args)
{
C objC = new C();
Console.Read();
}
[/Code]
Result:
The result will be:
In A
In B
In C
Labels:
c#,
Default Constructor,
Dotnet Interview Question,
Inheritance,
oops
Tuesday, March 29, 2011
What are the problems/challenges you faced in your previous projects?
"What are the problems/challenges you faced in your previous projects?"
To answer this question, you have to think of all projects you handled and prepare a list of challenges you faced and how you resolved them. If you don't prepare this list, it will be difficult to remember all points at the time of interview.
I will list down few problems that I faced in my previous projects. That will help you prepare a list for yourself.
Challenge 1
Challenge: This is the biggest challenge I faced. The Production web application connecting to the Crystal Enterprise server was always down. The client was very upset and was using the UAT web application to run Ad-hoc query in Crystal Enterprise server.Resolution: After a long research on Crystal Enterprise server, IIS, Web application settings, application pools etc for about 3 months, I got the answer.
Another application installed in the same application Pool was causing this web application down when there was any run time error in that application. I resolved the issue by separating the Application Pools for each web applications.
Challenge 2
Challenge: I was part of a Unit Testing team in a big project. We were doing Unit Testing in VSTS (Visual Studio Team System). The challenge was to achieve the code coverage above 90% and to automate the input data for test cases above 95%.Resolution:
Code coverage - To achieve code coverage above 90% is very difficult task as it is very difficult to write test cases to prodecue all type of exceptions and reach all the catch block code. We put all our innovations to produce maximum type of exceptions and managed to keep code cpoverage above 90%.
Automating Test Data - We faced difficulty in automating test data for many scenarios. We put lots of innovations to automate test data above 95% level.
i) We used SQL query to retrieve test data dynamically and it helped automating test data for many scenarios.
ii) We organised the sequence of execution of few test cases and that helped for some scenarios. Example of a sequence: Create, Edit, Delete
You can post comments about some of the challenges you faced for others to learn & benefit from you.
Sunday, March 6, 2011
Wednesday, January 12, 2011
Find number of words in a text file in C# Dotnet
using System;
using System.IO;
namespace ConsoleApplication1
{
class CountWords
{
public string content { get; set; }
internal int wordsInFile(string P)
{
return File.ReadAllText(P).Split(' ').Length;
}
}
class Program
{
static void Main(string[] args)
{
CountWords c = new CountWords();
int numWords = c.wordsInFile(@"C:\test_data.txt");
Console.WriteLine(numWords);
Console.ReadLine();
}
}
}
Text and Speech Project in C# Dotnet
Labels:
c# dotnet code,
count words in a file
Thursday, October 7, 2010
Is XML case sensitive?
Opening and closing tags must be written with the same case:
<Message>This is incorrect</message>
<message>This is correct</message>
Labels:
Dotnet Interview Question,
XML
Sunday, May 2, 2010
What are Modal and Modeless forms in Windows Forms Application?
Modal Form:
In a modal form Windows application, the last form opened can only be accessed. i.e. the parent form cannot be accessed as long as the child form is open.Modeless Form:
In case of Modeless form, Parent window generates a child window (as in Modal forms), but the user can access either of the Parent window or Child Window.Tuesday, March 16, 2010
Drop Delete Truncate in SQL Server
Delete Command in SQL:
Delete Command is used to delete records from a table.
Syntax: DELETE FROM Table_Name [WHERE Condition]
Note that the where condition is optional and the rows are deleted based on the where condition.
Ex: DELETE FROM Employee WHERE EmpID=50
It means that the row with EmpID=50 will be only deleted.
If there is no Where condition, the entire data will be deleted from that table.
Ex: DELETE FROM Employee
It will delete all the records from Employee table.
Truncate Command in SQL:
Truncate Command is used to delete all the records from a table and frees the space in disc.
Syntax: TRUNCATE TABLE Table_Name
Ex: TRUNCATE TABLE Department
Difference between Delete and Truncate Command:
Delete Command deletes records from a table based on a condition or deletes all the records if no condition is specified. But it doesn't free the space.
Truncate Command deletes all the records from a table as well as frees up the space.
Drop Command in SQL:
Drop command is used to remove an Object from a database. When Drop Table command is used, it deletes all rows from that table, then removes the table from the database and removes all references to that table.
Syntax: DROP TABLE Table_Name
Ex: DROP TABLE Department
Difference between Drop and Truncate Command in SQL:
Truncate Command removes all rows from a table, but the table structure, all relationships, constraints remain in the Database.
But Drop Command removes the entire table, all relationships associated with that table, all constraints in that table.
We can insert new records in a truncated table. But it is not possible when a table is dropped as it doesn't exist.
Labels:
Delete,
Drop,
SQL Server,
Truncate command in SQL
Subscribe to:
Posts (Atom)


