Thursday, July 23, 2009

Web Services

1. Which attribute is used in order that the method can be used as WebService ?
WebMethod attribute has to be specified in order that the method and property can be treated as WebService.
2. Do webservice have state ?
Twist :- How can we maintain State in Webservices ?
Webservices as such do not have any mechanism by which they can maintain state.
3. How to Authentication for Web Services
using SOAP headers
4. HOW TO: Pass Current Credentials to an ASP.NET Web Service
myProxy.Credentials = System.Net.CredentialCache.DefaultCredentials
localhost.MyWebService myService = new localhost.MyWebService();
System.Net.CredentialCache myCredentials = new System.Net.CredentialCache();
NetworkCredential netCred = new NetworkCredential("UserName", "Password");
myCredentials.Add(new Uri(myService.Url), "Basic", netCred);
myService.Credentials = myCredentials;
DataSet dsPartDetails = new DataSet();
Item[] arrPartDetails = null;
arrPartDetails = objSrchPartsCommonMethods.GetPartService(vendorPartNum, manPartNum);
dsPartDetails = objSrchPartsCommonMethods.ConvertArrayToDataSet(arrPartDetails);

public FirstSolarMasterDataServices.Item[] GetPartService(string partNumber, string manPartNum)
FirstSolarMasterDataServices.MasterData objFirstSolarERPWebService = new FirstSolarMasterDataServices.MasterData();
FirstSolarMasterDataServices.Item[] arrParts;

objFirstSolarERPWebService = ImpersonateDevUser();

//Calling Web services menthods
arrParts = objFirstSolarERPWebService.GetItems(ConfigurationManager.AppSettings["CompanyId"].ToString(), "", partNumber, "","",manPartNum);
return arrParts;
//code used at Onsite
//comment this code at ODC

// if (m_Ctx != null)
// {
// m_Ctx.Undo();
// }

private FirstSolarMasterDataServices.MasterData ImpersonateDevUser()
FirstSolarMasterDataServices.MasterData objFirstSolarErpModifyWebService = new FirstSolarMasterDataServices.MasterData();

//code used at ODC
//comment this code at Onsite

NetworkCredential nwCredentials = new NetworkCredential();

nwCredentials.UserName = ConfigurationManager.AppSettings["NWUserName"].ToString();
nwCredentials.Password = ConfigurationManager.AppSettings["NWPassword"].ToString();
nwCredentials.Domain = ConfigurationManager.AppSettings["NWDomain"].ToString();

//Assignign credentials to web services
objFirstSolarErpModifyWebService.Credentials = new NetworkCredential(nwCredentials.UserName, nwCredentials.Password, nwCredentials.Domain);


//code used at Onsite
//comment this code at ODC

//m_Ctx = WindowsIdentity.GetCurrent().Impersonate();

//objFirstSolarERPModifyWebService.Url = ModifyWebService;

// //We have to authenticate ourselves with the web service.
//objFirstSolarERPModifyWebService.PreAuthenticate = true;
//objFirstSolarERPModifyWebService.Credentials = System.Net.CredentialCache.DefaultCredentials;


return objFirstSolarErpModifyWebService;
Covert Arrat to Dataset
public DataSet ConvertArrayToDataSet(Object[] objArray)
XmlTextReader reader;
DataSet arrayDataSet = new DataSet();
MemoryStream memStream = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(memStream, System.Text.Encoding.UTF8);
XmlSerializer serializer = new XmlSerializer(objArray.GetType());
serializer.Serialize(writer, objArray);
memStream.Position = 0;
reader = new XmlTextReader(memStream);

return arrayDataSet;
catch (Exception ex)

Tuesday, July 21, 2009

Use Data View

protected void BindEmployee()
ConnectDB objConnectDB = null;
SqlConnection objSqlConnection = null;
SqlCommand objSqlCommand = null;
SqlDataAdapter objSqlDataAdapter = null;
DataSet objDataSet = null;
objConnectDB = new ConnectDB();
objSqlConnection = objConnectDB.getConnection();
objDataSet = new DataSet();
//string strSQL = "SELECT GUID,FirstName+' '+coalesce(LastName,'') as FullName from TblEmployeeInfo where active=1 order by FirstName+' '+coalesce(LastName,'')";
string strSQL = "SELECT GUID, FirstName+' '+coalesce(LastName,'') as FullName, REPLACE(FirstName+' '+coalesce(LastName,''),'''','\\''') as FullNameRead from TblEmployeeInfo where active=1 order by FirstName+' '+coalesce(LastName,'')";

objSqlCommand = new SqlCommand(strSQL, objSqlConnection);
objSqlDataAdapter = new SqlDataAdapter(objSqlCommand);


if (txtFilter.Text == "")
grdvwEmployee.DataSource = objDataSet.Tables[0];
//DataView dv = new DataView(objDataSet.Tables[0], "FullName like '%" + txtFilter.Text.Trim() + "%'", "", DataViewRowState.CurrentRows);
DataView dv = new DataView(objDataSet.Tables[0], "FullName like '%" + txtFilter.Text.Trim().Replace("'", "") + "%'", "", DataViewRowState.CurrentRows);
grdvwEmployee.DataSource = dv;


catch (Exception ex)
lblMsg.Text = "Error: " + ex.Message;

Monday, July 20, 2009

Get Selected result with Comma separate

CREATE TABLE dbo.tblItems
ItemID int NOT NULL IDENTITY (1, 1),
ItemName nvarchar(50) NOT NULL
( ItemID )

Insert into dbo.tblItems (ItemName) Values ('Item1')
Insert into dbo.tblItems (ItemName) Values ('Item2')
Insert into dbo.tblItems (ItemName) Values ('Item3')
Insert into dbo.tblItems (ItemName) Values ('Item4')

Declare @m_ItemsList nvarchar(2000)
Select @m_ItemsList=''
Select @m_ItemsList=@m_ItemsList+ItemName+',' from tblItems
Select Left(@m_ItemsList,Len(@m_ItemsList)-1)

Tuesday, July 14, 2009

Monday, July 13, 2009

Javascript with DIV for tool tip

Javascript with DIV for tool tip

style="cursor: hand; ime-mode: active; color: Red">[?]

*Part Type:

*Preventative Maintenance
onmouseover="'visible'" />

Sunday, July 12, 2009

Dot Net FAQs

ExecuteNonQuery-returns number of rows effected
ExecuteReader-It will return SQLDatareader(Set of records)
ExecuteScalar-It will return last inserted row value.

GAC- C:\WINDOWS\assembly
ILDASM.EXE- C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin
Q)IS there any way to restrict the Developer to delete a assembly? How can i do? pros and cons?
Ans.Yes,By placing the assembly in to GAC.

This statements will be usefull while uploading large files from .Net to server
System.GC.Collect()- forces garbage collector to run

1) What are situations when you register .NET assembly in GAC ?

2) What’s the difference between Cache object and application object ?

The main difference between the Cache and Application objects is that the Cache object
provides cache-specific features, such as dependencies and expiration policies.

3) When we use Cache object and when we use application object?

4) How can get access to cache object ?

You can get a reference
to the Cache object by using the Cache property of the HttpContext class

5) Where do you specify session state mode in ASP.NET ?

6)What are benefits and limitations of using Cookies?

7)How u define the cookie in ASP.Net?
Request.Cookies.Add(New HttpCookie(“name”, “user1”))

8)How cross page posting can be achieved in ASP.Net?
PostBackUrl="~/nextpage.aspx" Text="Post to nextpage" />

9)How delegates used for event handling?

10)Can you prevent a class from overriding ?

11)What is the significance of Finalize method in .NET?

12)When we required System.StringBuilder classes?

13)How can we skip some set of code from the Page PostBack?

14)Where is ViewState information stored ?
In HTML Hidden Fields.

15)How can you enable automatic paging in DataGrid ?

16)What is the method to customize columns in DataGrid?
Use the template column.

17)What are major events in GLOBAL.ASAX file ?What order they are triggered ?

18)where do we enable tracing ?
<%@ Page Trace="true" %>

19) How to kill a session in


20) How can I track event in checkbox which is one of the columns of a datagrid ?

21) What is difference between Constant and readonly properties?

get accessor in property implemantation.

22) Is structure can be inherited?

23) what is difference between static variable and private variable?

24) What is use of virtual method in a base class?

25) When we require interface? when we require abstract?

26) what is use of out parameter in c#?

27) what is the scope of extern variable?

28) what is use of static constructor?

29) What is the difference between is and as?
The AS operator is used to perform certain type of conversion between compatible reference types.
IS checks if object is compatiable with a given type.

30) What is scope of access modifers like internal,protected?

31) what is the use of partial classes?

32) What is the use of “OverRides” and “Overridable” keywords ?
Overridable is used in parent class to indicate that a method can be overridden. Overrides
is used in the child class to indicate that you are overriding a method

33)In what instances you will declare a constructor to be private?
When we create a private constructor, we can not create object of the class directly from
a client. So you will use private constructors when you do not want instances of the class
to be created by any external client. Example UTILITY functions in project will have no
instance and be used with out creating instance, as creating instances of the class would
be waste of memory.

34)Can two catch blocks be executed?
No, once the proper catch section is executed the control goes finally to block. So there
will not be any scenarios in which multiple catch blocks will be executed.

35)What is impersonation in ASP.NET ?
By default, ASP.NET executes in the security context of a restricted user account on the
local machine. Sometimes you need to access network resources such as a file on a shared
drive, which requires additional permissions. One way to overcome this restriction is to
use impersonation. With impersonation, ASP.NET can execute the request using the
identity of the client who is making the request, or ASP.NET can impersonate a specific
account you specify in web.config.

36)Can you explain in brief how the ASP.NET authentication process works?
ASP.NET does not run by itself, it runs inside the process of IIS. So there are two
authentication layers which exist in ASP.NET system. First authentication happens at
the IIS level and then at the ASP.NET level depending on the WEB.CONFIG file.
Below is how the whole process works:-
v IIS first checks to make sure the incoming request comes from an IP address
that is allowed access to the domain. If not it denies the request.
v Next IIS performs its own user authentication if it is configured to do so. By
default IIS allows anonymous access, so requests are automatically
authenticated, but you can change this default on a per – application basis
with in IIS.
v If the request is passed to with an authenticated user, checks
to see whether impersonation is enabled. If impersonation is enabled,
acts as though it were the authenticated user. If not acts with its own
configured account.
v Finally the identity from step 3 is used to request resources from the operating
system. If authentication can obtain all the necessary resources it
grants the users request otherwise it is denied. Resources can include much
more than just the page itself you can also use .Net’s code access
security features to extend this authorization step to disk files, Registry keys
and other resources.

37)How can we check if all the validation control are valid
and proper ?
Using the Page.IsValid() property you can check whether all the validation are done

38)What are the two fundamental objects in ADO.NET ?
Datareader and Dataset are the two fundamental objects in ADO.NET.

39)What is the use of command objects ?
They are used to connect connection object to Datareader or dataset. Following are the
methods provided by command object :-
v ExecuteNonQuery :- Executes the command defined in the CommandText
property against the connection defined in the Connection property for a query
that does not return any row (an UPDATE, DELETE or INSERT). Returns
an Integer indicating the number of rows affected by the query.
v ExecuteReader :- Executes the command defined in the CommandText property
against the connection defined in the Connection property. Returns a "reader"
object that is connected to the resulting rowset within the database, allowing
the rows to be retrieved.
v ExecuteScalar :- Executes the command defined in the CommandText property
against the connection defined in the Connection property. Returns only
single value (effectively the first column of the first row of the resulting rowset)
any other returned columns and rows are discarded. It is fast and efficient
when only a "singleton" value is required

What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
You can use Having Clause with the GROUP BY function in a query and WHERE
Clause is applied to each row before they are part of the GROUP BY function in a query.

(B) What is the difference between UNION and UNION ALL SQL syntax ?
UNION SQL syntax is used to select information from two tables. But it selects only
distinct records from both the table, while UNION ALL selects all records from both the

When listing product information you might want to draw the user's eye to products that
are out of stock. one way to accomplish this would be to change the back ground colour of those
rows with unit in stock value of 0.

The gridview offers a onRowDataBound event that fires once for each row after the row has been creted
and bound to corresponding record of data from the data source control.


1.architecture of .net
2.What is IL and CLR
3.Collections -Arrary, array list , hash array
4.How can we handile exception in .Net and SQL server--
5.Tell me simple steps to bind a grid using sql connection
6.State management-
7.Diff b/w Session and application memory
8.How to swap 2 values with out using temp
9.Overriding and Overloading
10. Dataset and reader...
11. Can we run all versions of .Net applications in same server.
12.One array size is 100, i have entered 99 records(Numbers from 1 to 100) in that array, how can i find missed value.
13.I have 2 arrays with diff size, i want to dispaly matched records and unmatched recores.
14..Net is plat form independent.
15. Tell me what are the namespaces we use to work with ajax. (Ans: System.Web.Extensions, System.Web.Extensions.Design)
16. Can my application can have more that 1 .config files...YES
17.Can i have more that one DLL with same name in my system. Ans)Yes in GAC it is possible
18.Diff b/w EXE and DLL
19.How can we improve application erformance.
22. architecture of u r current application. how can u support u r architecture is sutable for u r aplication. can we call webservices.

Tell u have a knowledge on workflows.....which u have..
1.what is workflow.
2.what is the use of workflows

Diff b/w function and SP in SQL
New features in sql 2005 that 2000
what is index in sql and advantages, diss adva?

How to get inserted row identity value from Database in SP?
If you are using SQL Server 7.0, simply change the line in the stored procedure from ...


... to ...