Thursday, December 31, 2009

Setting Up PayPal Sandbox To Our Web Forms

I had a fair bit of trouble getting the sandbox setup properly for paypal so I thought I would put some steps down to make it a bit more easier for anyone just getting started with setting up the pay pal sandbox.

1 - Go to https://developer.paypal.com/ and click the sign up now button. create an account (your username must be a different one if you have a paypal account)

2 - Click on Test Accounts, and add a business and personal account (note that if you are an australian you cant get the API keys without selecting US from the where do you live dropdown). Take note of the passwords that you use. When you create an account it creates a test bank account and test credit card for you to test your code with. You can also take note of these details for use later on in your testing.

3 - Click on API credentials, and take note of your API account, username, password and Signature. These are obviously used within your code config.

4 - Click on Test Accounts, and making sure your business account is selected, click on the enter sandbox test site button.

5 - Sign into your test site with your business account users details, your business accounts username should already be pre-filled in on the login form. Note that you must login with your business account details and not your API credentials.

6 - In the My Account Overview page, click on the step buttons to confirm your details and setup the api permissions.

7 - Most of the standard methods are activated once you have done this, but some are not. To check your api permissions click on my account/profile to go to your profile summary, then in your account information links click on API Access. Check the boxes next to the API's you wish to use, then click submit.

8 - You will prolly need some funds in your account if you are using payment methods such as mass pay, so click the Add Funds button and add some cash. Note that this is for testing use only and the money transfer is from a fictional bank.

9- These funds that you transferred need to be cleared, go to my accounts and scroll down to the bottom, you will see the fund transfers in the list, click on details link for that transaction, then click on clear transaction to complete the process.

That should be it, double check you have your API credentials setup properly in your code and you should be able to hit the sandbox for testing.

happy coding :)

Friday, December 18, 2009

what is the difference between .net2.0 and .net3.5

The .NET Framework 3.0 is Microsoft's managed code programming model. It is a superset of the .NET Framework 2.0, combining .NET Framework 2.0 components with new technologies for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes. In addition to the .NET Framework 2.0, it includes Windows Presentation Foundation (WPF), Windows Workflow Foundation (WF), Windows Communication Foundation (WCF), and Windows CardSpace.

Net 3.0 is an add-on to .Net 2.0. It contains three
Libraries for Windows
Presentation Foundation (WPF), Windows Workflow Foundation
(WF) and Windows
Communication Foundation (WCF) (and Windows Cardspace).
You can use these in
Visual Studio 2005 by adding extensions.

.Net 3.5 is the next .Net version after 2.0 shipped with
Visual Studio 2008


.NET 3.5 has LINQ, ASP.NET AJAX, new controls, richer WCF support, and a few other features that aren't in .NET 3.0. For server/asp.net scenarios I'd probably always recommend going with .NET 3.5. For client scenarios, .NET 3.0 is interesting to target since is pre-installed on all versions of Windows Vista - so you have good deployment of the runtime.


Note that all applications that target .NET 3.0 or .NET 2.0 will work run on .NET 3.5. You can't use the new features in .NET 3.5 if you target .NET 3.0 - but your application will obviously still work

What are the differences between Dataset and DataReader


Dataset is in memory representation of the Database. where 
you can create tables, relations between tables, add 
primary key to tables and also manipulate the data 
retrieved form the database. It allows us to work in 
connection less environment.
 
Datareader is like forward only readonly cursor, which is 
used to retrieve data. data manipulation is not possible 
while using datareader. datareader continously keeps the 
connection open.
 
A ds (dataset) can be used when the connection is closed.
A dr (datareader) needs the connection open to be used.
A ds can be used to modify or delete or insert data in the 
database. 
A data reader can be used only to read data
 
A ds can let you access the info on any order at any time.
A dr lets you access the info only one time per item and 
only in a sequential order.
 
A ds data can be loaded in longer time than a dr can be 
loaded at.
 
A ds can contain separated and structured data from several 
database tables. 
A dr can contain data in one register per item, that 
register can include data from serveral tables id the sql 
select statement so indicates, but it has no separate 
structure per table.


Thursday, December 17, 2009

Check All Checkbox In GridView To Bulk Edit Or Update ASP.NET C# NET

 chkselect all put autopostback=true;
 
protected void chkSelectAll_CheckedChanged
                               (object sender, EventArgs e)
{
 CheckBox chkAll = 
    (CheckBox)GridView1.HeaderRow.FindControl("chkSelectAll");
 if (chkAll.Checked == true)
 {
   foreach (GridViewRow gvRow in GridView1.Rows)
   {
    CheckBox chkSel = 
         (CheckBox)gvRow.FindControl("chkSelect");
    chkSel.Checked = true;
    TextBox txtname = (TextBox)gvRow.FindControl("txtName");
    TextBox txtlocation = (TextBox)gvRow.FindControl("txtLocation");
    txtname.ReadOnly = false;
    txtlocation.ReadOnly = false;
    txtname.ForeColor = System.Drawing.Color.Black;
    txtlocation.ForeColor = System.Drawing.Color.Black;
   }
 }
 else
 {
  foreach (GridViewRow gvRow in GridView1.Rows)
  {
   CheckBox chkSel = (CheckBox)gvRow.FindControl("chkSelect");
   chkSel.Checked = false;
   TextBox txtname = (TextBox)gvRow.FindControl("txtName");
   TextBox txtlocation = (TextBox)gvRow.FindControl("txtLocation");
   txtname.ReadOnly = true;
   txtlocation.ReadOnly = true;
   txtname.ForeColor = System.Drawing.Color.Blue;
   txtlocation.ForeColor = System.Drawing.Color.Blue;
   }
  }
}

Wednesday, December 16, 2009

using error Provider for Registration Page using windowes Applications

errorProvider1.Clear();
            if (txtName.Text == "")
            {
                errorProvider1.SetError(txtName, "Enter your Name");
                return;
            }
            if (txtUser.Text == "")
            {
                errorProvider1.SetError(txtUser , "Enter UserName");
                return;
            }
            if (txtPwd.Text == "")
            {
                errorProvider1.SetError(txtPwd , "Enter your Password");
                return;
            }
            if (txtContact.Text == "")
            {
                errorProvider1.SetError(txtContact, "Enter your Contact Number");
                return;
            }
            if (txtAddress.Text == "")
            {
                errorProvider1.SetError(txtAddress, "Enter your Address");
                return;
            }
            string gender;
            if (rbFemale.Checked == true)
            {
                gender = "Female";
            }
            else
            {
                gender = "Male";
            }
            try
            {
                d.command("insert into watermarking values('" + txtName.Text + "','" + cbAge.SelectedItem.ToString() + "','" + gender + "','" + txtAddress.Text + "','" + txtContact.Text + "','" + txtUser.Text + "','" + txtPwd.Text + "')");
                MessageBox.Show("succcessfully saved","message");
                txtName.Text = "";
                cbAge.SelectedIndex = 0;
                txtContact.Text = "";
                txtAddress.Text = "";
                txtUser.Text = "";
                txtPwd.Text = "";
                txtConfirm.Text = "";
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            txtName.Text = "";
            cbAge.SelectedIndex = 0;
            txtContact.Text = "";
            txtAddress.Text = "";
            txtUser.Text = "";
            txtPwd.Text = "";
            txtConfirm.Text = "";

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void txtConfirm_TextChanged(object sender, EventArgs e)
        {
            if (txtConfirm.Text != txtPwd.Text)
            {
                errorProvider1.SetError(txtConfirm, "Please Enter Same Password");
            }
            else
            {
                errorProvider1.Clear();

            }
        }
    }
}

Thursday, December 10, 2009

inserting And retrive The data using Xml

   
        jobs for all Catagories
        View Jobs

   

   
        View Jobs
       
       

        Applynow
       

        Home
   

   
        Select Your Job
       
       

        Give Your Name
       

       
       

        Email id
       

       
       

        Apply Now
       

       

        Label
   

   
   




Coding
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class applyjobs : System.Web.UI.MobileControls.MobilePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            DataSet ds = new DataSet();
            ds.ReadXml(MapPath("jobs1.xml"));
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                List1.Items.Add(dr["catagory_Text"].ToString());
                SelectionList1.Items.Add(dr["catagory_Text"].ToString());
            }
        }
    }
    protected void btnApply_Click(object sender, EventArgs e)
    {
        DataSet ds1 = new DataSet();
        ds1.ReadXml(MapPath("Appiled.xml"));
        DataRow dr = ds1.Tables[0].NewRow();
        dr[0] = txtusername.Text;
        dr[1] = txtEmail.Text;
        dr[2] = SelectionList1.Items[SelectionList1.SelectedIndex].Value;
        ds1.Tables[0].Rows.Add(dr);
        ds1.WriteXml(MapPath ("Appiled.xml"));
        lblmsg.Visible = true;
        lblmsg.Text = "SucessFully Submitted Your Deatails";

    }
}

Tuesday, December 8, 2009

C# Interview Questions


This is a list of questions I have gathered from other sources and created myself over a period of time from my experience, many of which I felt where incomplete or simply wrong.  I have finally taken the time to go through each question and correct them to the best of my ability.  However, please feel free to post feedback to challenge, improve, or suggest new questions.  I want to thank those of you that have contributed quality questions and corrections thus far.
There are some question in this list that I do not consider to be good questions for an interview.  However, they do exist on other lists available on the Internet so I felt compelled to keep them easy access.
General Questions
  1. Does C# support multiple-inheritance?
    No.
     
  2. Who is a protected class-level variable available to?
    It is available to any sub-class (a class inheriting this class).
     
  3. Are private class-level variables inherited?
    Yes, but they are not accessible.  Although they are not visible or accessible via the class interface, they are inherited.
     
  4. Describe the accessibility modifier “protected internal”.
    It is available to classes that are within the same assembly and derived from the specified base class.
     
  5. What’s the top .NET class that everything is derived from?
    System.Object.
     
  6. What does the term immutable mean?
    The data value may not be changed.  Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.

     
  7. What’s the difference between System.String and System.Text.StringBuilder classes?
    System.String is immutable.  System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
     
  8. What’s the advantage of using System.Text.StringBuilder over System.String?
    StringBuilder is more efficient in cases where there is a large amount of string manipulation.  Strings are immutable, so each time a string is changed, a new instance in memory is created.
     
  9. Can you store multiple data types in System.Array?
    No.
     
  10. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
    The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array.  The CopyTo() method copies the elements into another existing array.  Both perform a shallow copy.  A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array.  A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.
     
  11. How can you sort the elements of the array in descending order?
    By calling Sort() and then Reverse() methods.
     
  12. What’s the .NET collection class that allows an element to be accessed using a unique key?
    HashTable.
     
  13. What class is underneath the SortedList class?
    A sorted HashTable.
     
  14. Will the finally block get executed if an exception has not occurred?­
    Yes.
     
  15. What’s the C# syntax to catch any possible exception?
    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 {}.
     
  16. Can multiple catch blocks be executed for a single try statement?
    No.  Once the proper catch block processed, control is transferred to the finally block (if there are any).
     
  17. Explain the three services model commonly know as a three-tier application.
    Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).
     
Class Questions
  1. What is the syntax to inherit from a class in C#?
    Place a colon and then the name of the base class.
    Example: class MyNewClass : MyBaseClass
     
  2. Can you prevent your class from being inherited by another class?
    Yes.  The keyword “sealed” will prevent the class from being inherited.
     
  3. Can you allow a class to be inherited, but prevent the method from being over-ridden?
    Yes.  Just leave the class public and make the method sealed.
     
  4. What’s an abstract class?
    A class that cannot be instantiated.  An abstract class is a class that must be inherited and have the methods overridden.  An abstract class is essentially a blueprint for a class without any implementation.
     
  5. When do you absolutely have to declare a class as abstract?
    1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
    2. 
    When at least one of the methods in the class is abstract.
     
  6. What is an interface class?
    Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.
     
  7. Why can’t you specify the accessibility modifier for methods inside the interface?
    They all must be public, and are therefore public by default.
     
  8. Can you inherit multiple interfaces?
    Yes.  .NET does support multiple interfaces.
     
  9. What happens if you inherit multiple interfaces and they have conflicting method names?
    It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
    To Do: Investigate
     
  10. What’s the difference between an interface and abstract class?
    In an interface class, all methods are abstract - there is no implementation.  In an abstract class some methods can be concrete.  In an interface class, no accessibility modifiers are allowed.  An abstract class may have accessibility modifiers.
     
  11. What is the difference between a Struct and a Class?
    Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval.  Another difference is that structs cannot inherit.
     
Method and Property Questions
  1. What’s the implicit name of the parameter that gets passed into the set method/property of a class?
    Value.  The data type of the value parameter is defined by whatever data type the property is declared as.
     
  2. What does the keyword “virtual” declare for a method or property?
    The method or property can be overridden.
     
  3. How is method overriding different from method overloading?
    When overriding a method, you change the behavior of the method for the derived class.  Overloading a method simply involves having another method with the same name within the class.
     
  4. Can you declare an override method to be static if the original method is not static?
    No.  The signature of the virtual method must remain the same.  (Note: Only the keyword virtual is changed to keyword override)
     
  5. What are the different ways a method can be overloaded?
    Different parameter data types, different number of parameters, different order of parameters.
     
  6. If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
    Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
     
Events and Delegates
  1. What’s a delegate?
    A delegate object encapsulates a reference to a method.
     
  2. What’s a multicast delegate?
    A delegate that has multiple handlers assigned to it.  Each assigned handler (method) is called.
     
XML Documentation Questions
  1. Is XML case-sensitive?
    Yes.
     
  2. What’s the difference between // comments, /* */ comments and /// comments?
    Single-line comments, multi-line comments, and XML documentation comments.
     
  3. How do you generate documentation from the C# file commented properly with a command-line compiler?
    Compile it with the /doc switch.
     
Debugging and Testing Questions
  1. What debugging tools come with the .NET SDK?
    1.   CorDBG – command-line debugger.  To use CorDbg, you must compile the original C# file using the /debug switch.
    2.   DbgCLR – graphic debugger.  Visual Studio .NET uses the DbgCLR.
     
  2. What does assert() method do?
    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.
     
  3. What’s the difference between the Debug class and Trace class?
    Documentation looks the same.  Use Debug class for debug builds, use Trace class for both debug and release builds.
     
  4. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
    The tracing dumps can be quite verbose.  For applications that are constantly running you run the risk of overloading the machine and the hard drive.  Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.
     
  5. Where is the output of TextWriterTraceListener redirected?
    To the Console or a text file depending on the parameter passed to the constructor.
     
  6. How do you debug an ASP.NET Web application?
    Attach the aspnet_wp.exe process to the DbgClr debugger.
     
  7. What are three test cases you should go through in unit testing?
    1.       Positive test cases (correct data, correct output).
    2.       Negative test cases (broken or missing data, proper handling).
    3.       Exception test cases (exceptions are thrown and caught properly).
     
  8. Can you change the value of a variable while debugging a C# application?
    Yes.  If you are debugging via Visual Studio.NET, just go to Immediate window.
     
ADO.NET and Database Questions
  1. What is the role of the DataReader class in ADO.NET connections?
    It returns a read-only, forward-only rowset from the data source.  A DataReader provides fast access when a forward-only sequential read is needed.
  2.  
  3. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
    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.  OLE-DB.NET is a .NET layer on top of the OLE layer, so it’s not as fastest and efficient as SqlServer.NET.
     
  4. 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. The wildcard character is %, the proper query with LIKE would involve ‘La%’.
     
  5. Explain ACID rule of thumb for transactions.
    A transaction must be:
    1.       Atomic - it is one unit of work and does not dependent on previous and following transactions.
    2.       Consistent - data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t.
    3.       Isolated - no transaction sees the intermediate results of the current transaction).
    4.       Durable - the values persist if the data had been committed even if the system crashes right after.
     
  6. What connections does Microsoft SQL Server support?
    Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and password).
     
  7. Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted?
    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.
     
  8. What does the Initial Catalog parameter define in the connection string?
    The database name to connect to.
     
     
  9. What does the Dispose method do with the connection object?
    Deletes it from the memory.
    To Do: answer better.  The current answer is not entirely correct.
     
  10. What is a pre-requisite for connection pooling?
    Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.  The connection string must be identical.
     
Assembly Questions
  1. How is the DLL Hell problem solved in .NET?
    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.
     
  2. What are the ways to deploy an assembly?
    An MSI installer, a CAB archive, and XCOPY command.
     
  3. What is a satellite assembly?
    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.
     
  4. What namespaces are necessary to create a localized application?
    System.Globalization and System.Resources.
     
  5. What is the smallest unit of execution in .NET?
    an Assembly.
     
  6. When should you call the garbage collector in .NET?
    As a good rule, you should not call the garbage collector.  However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory.  However, this is usually not a good practice.
     
  7. How do you convert a value-type to a reference-type?
    Use Boxing.
     
  8. What happens in memory when you Box and Unbox a value-type?
    Boxing converts a value-type to a reference-type, thus storing the object on the heap.  Unboxing converts a reference-type to a value-type, thus storing the value on the stack.

ASP.NET Interview Questions

ASP.NET Interview Questions
This is a list of questions I have gathered and created over a period of time from my experience, many of which I felt where incomplete or simply wrong.  I have finally taken the time to go through each question and correct them to the best of my ability.  However, please feel free to post feedback to challenge, improve, or suggest new questions.  I want to thank those of you that have contributed quality questions and corrections thus far.
There are some questions in this list that I do not consider to be good questions for an interview.  However, they do exist on other lists available on the Internet so I felt compelled to keep them here for easy access.
  1. Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
    inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.
     
  2. What’s the difference between Response.Write() andResponse.Output.Write()?
    Response.Output.Write() allows you to write formatted output.
     
  3. What methods are fired during the page load?
    Init() - when the page is instantiated
    Load() - when the page is loaded into server memory
    PreRender() - the brief moment before the page is displayed to the user as HTML
    Unload() - when page finishes loading.
     
  4. When during the page processing cycle is ViewState available?
    After the Init() and before the Page_Load(), or OnLoad() for a control.
     
  5. What namespace does the Web page belong in the .NET Framework class hierarchy?
    System.Web.UI.Page
     
  6. Where do you store the information about the user’s locale?
    System.Web.UI.Page.Culture
     
  7. What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?
    CodeBehind is relevant to Visual Studio.NET only.
     
  8. What’s a bubbled event?
    When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.
     
  9. Suppose you want a certain ASP.NET function executed on MouseOver for a certain button.  Where do you add an event handler?
    Add an OnMouseOver attribute to the button.  Example: btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();");
     
  10. What data types do the RangeValidator control support?
    Integer, String, and Date.
     
  11. Explain the differences between Server-side and Client-side code?
    Server-side code executes on the server.  Client-side code executes in the client's browser.
     
  12. What type of code (server or client) is found in a Code-Behind class?
    The answer is server-side code since code-behind is executed on the server.  However, during the code-behind's execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser.  But just to be clear, code-behind executes on the server, thus making it server-side code.
     
  13. Should user input data validation occur server-side or client-side?  Why?
    All user input data validation should occur on the server at a minimum.  Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user.
     
  14. What is the difference between Server.Transfer and Response.Redirect?  Why would I choose one over the other?
    Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser.  This provides a faster response with a little less overhead on the server.  Server.Transfer does not update the clients url history list or current url.  Response.Redirect is used to redirect the user's browser to another page or site.  This performas a trip back to the client where the client's browser is redirected to the new page.  The user's browser history list is updated to reflect the new address.
     
  15. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
    Valid answers are:
    · 
    A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
    ·  A DataSet is designed to work without any continuing connection to the original data source.
    ·  Data in a DataSet is bulk-loaded, rather than being loaded on demand.
    ·  There's no concept of cursor types in a DataSet.
    ·  DataSets have no current record pointer You can use For Each loops to move through the data.
    ·  You can store many edits in a DataSet, and write them to the original data source in a single operation.
    ·  Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
     
  16. What is the Global.asax used for?
    The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.
     
  17. What are the Application_Start and Session_Start subroutines used for?
    This is where you can set the specific variables for the Application and Session objects.
     
  18. Can you explain what inheritance is and an example of when you might use it?
    When you want to inherit (use the functionality of) another class.  Example: With a base class named Employee, a Manager class could be derived from the Employee base class.
     
  19. Whats an assembly?
    Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN
     
  20. Describe the difference between inline and code behind.
    Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.
     
  21. Explain what a diffgram is, and a good use for one?
    The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML.  A good use is reading database data to an XML file to be sent to a Web Service.
     
  22. Whats MSIL, and why should my developers need an appreciation of it if at all?
    MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.  MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer.
     
  23. Which method do you invoke on the DataAdapter control to load your generated dataset with data?
    The Fill() method.
     
  24. Can you edit data in the Repeater control?
    No, it just reads the information from its data source.
     
  25. Which template must you provide, in order to display data in a Repeater control?
    ItemTemplate.
     
  26. How can you provide an alternating color scheme in a Repeater control?
    Use the AlternatingItemTemplate.
     
  27. What property must you set, and what method must you call in your code, in order to bind the data from a data source to the Repeater control?
    You must set the DataSource property and call the DataBind method.
     
  28. What base class do all Web Forms inherit from?
    The Page class.
     
  29. Name two properties common in every validation control?
    ControlToValidate property and Text property.
     
  30. Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?
    DataTextField property.
     
  31. Which control would you use if you needed to make sure the values in two different controls matched?
    CompareValidator control.
     
  32. How many classes can a single .NET DLL contain?
    It can contain many classes.
     
Web Service Questions
  1. What is the transport protocol you use to call a Web service?
    SOAP (Simple Object Access Protocol) is the preferred protocol.
     
  2. True or False: A Web service can only be written in .NET?
    False
     
  3. What does WSDL stand for?
    Web Services Description Language.
     
  4. Where on the Internet would you look for Web services?
    http://www.uddi.org
     
  5. True or False: To test a Web service you must create a Windows application or Web application to consume this service?
    False, the web service comes with a test page and it provides HTTP-GET method to test.
     
State Management Questions
  1. What is ViewState?
    ViewState allows the state of objects (serializable) to be stored in a hidden field on the page.  ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.  ViewState is used the retain the state of server-side objects between postabacks.
     
  2. What is the lifespan for items stored in ViewState?
    Item stored in ViewState exist for the life of the current page.  This includes postbacks (to the same page).
     
  3. What does the "EnableViewState" property do?  Why would I want it on or off?
    It allows the page to save the users input on a form across postbacks.  It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser.  When the page is posted back to the server the server control is recreated with the state stored in viewstate.
     
  4. What are the different types of Session state management options available with ASP.NET?
    ASP.NET provides In-Process and Out-of-Process state management.  In-Process stores the session in memory on the web server.  This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server.  Out-of-Process Session state management stores data in an external data source.  The external data source may be either a SQL Server or a State Server service.  Out-of-Process state management requires that all objects stored in session are serializable.

Monday, December 7, 2009

Error: Debugging Failed Because Integrated Windows Authentication Is Not Enable

Error: Debugging Failed Because Integrated Windows Authentication Is Not Enabled

Authentication of the user who requested debugging was prevented by an authentication error. This can occur when you try to step into a Web application or an XML Web service. One cause of this error is that integrated Windows authentication is not enabled. To enable it, follow the steps in "To enable integrated Windows authentication."
If you have enabled integrated Windows authentication and this error still appears, it is possible that this error is caused because Digest Authentication for Windows Domain Servers is enabled. In this situation you should contact with your network administrator.

To enable integrated Windows authentication

  1. Log on to the Web server by using an administrator account.
  2. Click Start and then click Control Panel.
  3. In Control Panel, double-click Administrative Tools.
  4. Double-click Internet Information Services.
  5. Click the Web server node.
    A Web Sites folder opens underneath the server name.
  6. You can configure authentication for all Web sites or for individual Web sites. To configure authentication for all Web sites, right-click the Web Sites folder and then click Properties. To configure authentication for an individual Web site, open the Web Sites folder, right-click the individual Web site, and then click Properties.
    The Properties dialog box is displayed.
  7. Click the Directory Security tab.
  8. In the Anonymous access and authentication control section, click Edit.
    The Authentication Methods dialog box is displayed.
  9. Under Authenticated access, select Integrated Windows authentication.
  10. Click OK to close the Authentication Methods dialog box.
  11. Click OK to close the Properties dialog box.
  12. Close the Internet Information Services window.

To enable integrated Windows authentication in Windows Vista/IIS 7

  1. Log on to the Web server by using an administrator account.
  2. Turn on Windows Authentication and II6 Management Compatibility, if you have not previously done this, by following these steps:
    1. Click Start, click Control Panel and then click Programs.
    2. Under Programs and Features, click Turn Windows features on or off.
      The User Access Control dialog box appears and prompts you for permission to continue.
    3. Click Continue.
      The Windows Features dialog box appears.
    4. In the feature list, expand the Internet Information Services node.

    5. Under Internet Information Services, expand the World Wide Web Services node.
    6. Under World Wide Web Services, click Security.
    7. Click Windows Authentication.
    8. Under Internet Information Services, expand the Web Management Tools node.
    9. Under Web Management Tools, expand the IIS 6 Management Compatibility node, and select the IIS 6 Metabase and IIS 6 Configuration Compatibility check box.
    10. Under Web Management Tools, select IIS Management Console and Click OK.
    11. Restart the computer for these changes to take effect.
  3. Click Start and then, click Control Panel.
  4. Click Classic View, and then double-click Administrative Tools.
  5. In the Name column and double-click Internet Information Services (IIS) Manager.
  6. In the Connections column, expand the node for your server.
    A Web Sites folder opens underneath the server name.
  7. Expand the Web Sites node and click the Web site for which you want to enable integrated Windows authentication.
  8. The title of the center pane changes to the name of the Web site that you selected. In this pane, under the IIS heading, double-click Authentication.
    The title of the pane changes to Authentication.
  9. In the Authentication pane, in the Name column, right-click Windows Authentication and then click Enable.
  10. Close the Internet Information Services (IIS) Manager window.

Thursday, December 3, 2009

SQl Server Quieries

select a.donorname,b.ename from donor_details a,emp_details b

select top 2 * from emp_details order by username

select (sum(sal)) from emp_details

select (max(sal)) from emp_details

select distinct(desg) from emp_details

select * from emp_details where eid in (4 , 5,6)

select * from emp_details where eid =4 or eid =18 or eid=6

 select * from emp_details where ename ='bhargav' and password='kiran'

select count(0) as records from emp_details

select ename, email ,count(*)from emp_details group by ename , email

  select ename, email ,count(*)from emp_details group by ename

select distinct ename,email from emp_details group by ename , email

 select  ename from emp_details group by ename

select  ename,email,desg from emp_details group by ename , email ,desg
having desg = 't2'

SQL SERVER – Definition, Comparison and Difference between HAVING and WHERE Clause

In recent interview sessions in hiring process I asked this question to every prospect who said they know basic SQL. Surprisingly, none answered me correct. They knew lots of things in details but not this simple one. One prospect said he does not know cause it is not on this Blog. Well, here we are with same topic online.
Answer in one line is : HAVING specifies a search condition for a group or an aggregate function used in SELECT statement.
HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause.
A HAVING clause is like a WHERE clause, but applies only to groups as a whole, whereas the WHERE clause applies to individual rows. A query can contain both a WHERE clause and a HAVING clause. The WHERE clause is applied first to the individual rows in the tables . Only the rows that meet the conditions in the WHERE clause are grouped. The HAVING clause is then applied to the rows in the result set. Only the groups that meet the HAVING conditions appear in the query output. You can apply a HAVING clause only to columns that also appear in the GROUP BY clause or in an aggregate function. (Reference :BOL)
Example of HAVING and WHERE in one query:
SELECT titles.pub_id, AVG(titles.price)
FROM titles INNER JOIN publishers
ON titles.pub_id = publishers.pub_id
WHERE publishers.state = 'CA'
GROUP BY titles.pub_id
HAVING AVG(titles.price) > 10

Sometimes you can specify the same set of rows using either a WHERE clause or a HAVING clause. In such cases, one method is not more or less efficient than the other. The optimizer always automatically analyzes each statement you enter and selects an efficient means of executing it. It is best to use the syntax that most clearly describes the desired result. In general, that means eliminating undesired rows in earlier clauses.

SQL SERVER – Difference between DISTINCT and GROUP BY – Distinct vs Group By

What is difference between DISTINCT and GROUP BY?
A DISTINCT and GROUP BY usually generate the same query plan, so performance should be the same across both query constructs. GROUP BY should be used to apply aggregate operators to each group. If all you need is to remove duplicates then use DISTINCT. If you are using sub-queries execution plan for that query varies so in that case you need to check the execution plan before making decision of which is faster.
Example of DISTINCT:
SELECT DISTINCT Employee, Rank
FROM Employees

Example of GROUP BY:
SELECT Employee, Rank
FROM Employees
GROUP BY Employee, Rank

Example of GROUP BY with aggregate function:
SELECT Employee, Rank, COUNT(*) EmployeeCount
FROM Employees
GROUP BY Employee, Rank

instead of trigger raising in sqlserver 2005

A trigger is a database object similar to a stored procedure that executes in response to certain actions that occur in your database environment. SQL Server 2005 is packaged with three flavors of trigger objects: AFTER, data definition language (DDL), and INSTEAD-OF.
AFTER triggers are stored procedures that occur after a data manipulation statement has occurred in the database, such as a delete statement. DDL triggers are new to SQL Server 2005, and allow you to respond to object definition level events that occur in the database engine, such as a DROP TABLE statement. INSTEAD-OF triggers are objects that will execute instead of data manipulation statements in the database engine. For example, attaching an INSTEAD-OF INSERT trigger to a table will tell the database engine to execute that trigger instead of executing the statement that would insert values into that table.




alter trigger insteadofpro2 on pro instead of delete
as begin
declare @pno int;
declare @productname varchar(50);
declare @cost varchar(50);
declare @action1 varchar(100);
select @pno=d.pno from deleted d;
select @productname=d.productname from deleted d;
select @cost=d.cost from deleted d;
select @action1='delete record insted of ';
if(@cost=10000)
begin
raiserror ('Cannot deletd where sal =3000',16,1)
rollback
end
else
begin

commit
delete from pro where pno=@pno
insert into protrigger values(@pno,@productname,@cost,@action1,getdate())
print'record delete bfore insert';
end
end

Wednesday, December 2, 2009

After /for Trigger example Using Sqlserver2005

 A trigger is a database object that is attached to a table. In many aspects it is similar to a stored procedure. As a matter of fact, triggers are often referred to as a "special kind of stored procedure." The main difference between a trigger and a stored procedure is that the former is attached to a table and is only fired when an INSERT, UPDATE or DELETE occurs. You specify the modification action(s) that fire the trigger when it is created.
The following shows how to create a trigger that displays the current system time when a row is inserted into the table to which it is attached.


create trigger trg2 on pro for
insert 
as
declare @pno int;
declare @productname varchar(50);
declare @cost varchar(50);
declare @action1 varchar(100);

select @pno =i.pno from inserted i;
select @productname =i.productname from inserted i;
select @cost =i.cost from inserted i;
select @action1 = 'inserted record after insert trigger'
insert into protrigger(pno, productname, cost, action1, time1)values (@pno, @productname, @cost, @action1, getdate());
print'after insert Trigger find';
go