Tuesday, May 10, 2011

Warning: Null value is eliminated by an aggregate or other SET operation

Today when I was executing one of the crystal reports in my application. I came across an error message as “Warning: Null value is eliminated by an aggregate or other SET operation”. I then googled a lot and found that this error is coming when a field is having null values for which an aggregate function like sum,avd etc is executed in the SQL statement.


This error can be suppressed by adding the command as below prior to executing the SQL statement

SET ANSI_WARNINGS OFF

Thursday, April 21, 2011

Loading User Control dynamically in a asp.net webpage

First create user control as in your project ,for reference I am naming it as “WebUserControl.ascx”

Open the aspx page where you want to show the control. Here I am going to show the control when the user clicks on the button on my page. For this first add a reference of the user control “WebUserControl.ascx ‘” as shown below to my aspx page.

Once this is done simply drag a placeholder control from the tool box and add to the aspx page. Also drag a button to the aspx page, so that we can dynamically load the user control on button click.


Once you had added the Placeholder and the button, your aspx page will look as below


Go to the code behind page of you webpage and in the button click event and add the below code


Now run your website and click on the button on the page, you can see that the user control is dynamically loaded to your webpage.

Wednesday, December 8, 2010

How to check weather a username exists on a domain comtroller?.

The below code will help you to check wether a specified user exists on the domain controlller or not.


bool AdsVlaid = false;

string username = "it";

string domain="server";

string path = String.Format("WinNT://{0}/{1},user", domain, username);

try

{

DirectoryEntry.Exists(path);

AdsVlaid= true;

}

catch (Exception ex)

{

AdsVlaid = false;

MessageBox.Show(ex.Message);

// For WinNT provider DirectoryEntry.Exists throws an exception

// instead of returning false so we need to trap it.

}

For more infomation please visit the below links

http://www.codeproject.com/KB/system/everythingInAD.aspx

http://stackoverflow.com/questions/1329833/how-to-check-if-windows-user-account-name-exists-in-domain

How to check the User credential of a user with a domain controller?

The below code will help you to check the username and password of a user on a domain controller


System.DirectoryServices.AccountManagement.PrincipalContext PrincipalContext = new System.DirectoryServices.AccountManagement.PrincipalContext(System.DirectoryServices.AccountManagement.ContextType.Domain, "server");

bool AdsVlaid = PrincipalContext.ValidateCredentials("it", "13@mf3-25");

Tuesday, December 7, 2010

How to Configure ReportViewer for Remote Processing in Windows and Asp .net?

To configure a ReportViewer control for remote processing, specify a server report to use with the control. Follow these steps to select a server report:


1. Add the ReportViewer control from the Data section of the Toolbox to the form or Web page in your project.

2. In the ReportViewer Tasks smart tags panel, in Choose Report, select Server Report.

3. In the Report Server text box, type the report server URL. The default URL syntax is http://localhost/reportserver. The actual URL that is used in your installation might be different depending on how the report server virtual directory settings are configured.

4. In the Report Path text box, type the fully qualified path of a published report. The report path must start with a forward slash ( / ). The path must not include report URL parameters. The path consists of folders in the report server folder namespace and the name of the report. For example, if you installed the SQL Server 2005 sample report Company Sales on your report server, the report path might be /AdventureWorks Sample Reports/Company Sales.

5. Build or deploy the application to verify that the report appears correctly in your application. If you receive HTTP proxy errors, verify that the report server URL is correct. If you receive a compatibility error, confirm that the report server is a SQL Server 2005 instance.

6. Select the ReportViewer control and open the Properties window.

7. Set properties on the ReportViewer control to configure the report toolbar and run-time functionality. Use the reference documentation to learn about each property. For more information, see ReportViewer Properties.

For More Details


http://msdn.microsoft.com/en-us/library/ms252075(v=VS.80).aspx

Thursday, November 18, 2010

How to store more than one value in a asp.net dropdown using attributes?

The below code will help you to store an additional value in the dropdown and access it using JavaScript, Using the below logic you can also store more value in different attributes in the same list.

Wednesday, October 27, 2010

How to use Lamda Expression in list.FindIndex() c# to find the index of a charater in chracter array?.

The below code will help you to find the index of a charatecte from the list or array


string[] alphabet = {"A", "B", "C", "D","E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O","P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z","1","2","3","4","5","6","7","8","9","0"};

int index= alphabet.ToList().FindIndex(s => s == "G");.

X will contain the index of the character G in the list or array.

You can find more infomration regarding lamda expression from the below link

http://msdn.microsoft.com/en-us/library/bb397687.aspx