Tuesday, May 5, 2009

solution to fix CrystalReportViewer toolbar export / print button not working problem in asp.net 2.0

Hi,

I created my asp.net 2.0 web application on my xp professional sp2 workstation using visual studio 2.0 and crystal report 10. Till this point everything is working fine. I can see my crystal report properly, its print function, export function is working properly.

Once i deployed it in production, windows server 2003 machine. the crystal report viewer stopped showing the toolbar images, it just turned up as red cross with white background. when i click it nothing happened.

Solution : After doing some research with the help of uncle google, and trying various things as suggested by other online experts. following solution worked for me.

Copy CrystalReportWebFormViewer3 folder from development machine’s C:\Inetpub\wwwroot\aspnet_client\system_web\2_0_50727 (2_0_50727 becoz i m using .net 2.0 version.) and paste it to the production machine same location.

That is it. It worked for me. I hope it helps others too.

Happy programming.

Read more!

Tuesday, April 28, 2009

How to upload/Deploy Sql server 2000 database on a remote web server using Helm control panel and Enterprise Manager

I have an Asp.net 2.0 web application using sql server 2000 as back end. I want to deploy the web application on Web hosting company’s rented web server.

The deployment of the asp.net 2.0 is done easily using the FTP (example filezilla). But to deploy the Database is quite tricky.

(Steps using HELM control panel)

Step 1: we need to create a database on the server, by logging in to the server using the HELM control panel, (details of accessing the Helm control panel will be pro

vided by the Service provider). Login –> Domains –> select ur domain –> Click Database manager –> select Sql server 2000 icon –> click New database and give the desired database name (E.g. MyDB). It will create an empty database on the server.(Also, note down the IP address, Port Number used. if you cant see the ip address and port number(xxx.xxx.xxx.xxx,&&&&), ask your service provider to get you the detail of port number)

Step 2: Create the Database user, give the username n password that you will use to access the database from your web application / Enterprise manager (E.g. MyDBUser).

(Steps using your local development/testing machine to upload the sql server 2000 database.)

Step 3:

Open Enterprise Manager –> Select Register New Sql Server from left pane –> Registered Sql Sever Properties will popup as shown in the figure below. Key in the IP Address, Port No. (xxx.xxx.xxx.xxx,&&&&), without parenthesis. Give the username n pwd we just created in step 2

sql1

Step 4:

Once the Sql server is registered, you can use it like a local db and use DDL, DML statements very easily.

I hope the post helps people to understand deployment better.

If you like the post, please bookmark it and use friend connect to be my friend on this blog.

Happy Programming.

Read more!

Thursday, April 9, 2009

How to send email from Sql server 2000, Sql Server Agent, SqlMail

Some times we need to schedule a Sql Server Job for automatic execution on a certain date n time in Sql server 2000. This  Sql Server Agent Job could be execution of Stored procedure, system command, DTS, etc. Now, on the execution, we need sql server to notify by email to the concerned person in the company of the success or failure of the scheduled job.

Now, Sending an email from sql server 2000 is a bit tricky. Lets start doing it step by step. We will consider Sql Server machine is using Microsoft Exchange Server / Outlook. (There are other ways to do it. But I am considering it only thru MS exchange server.)

Step 1:

Go to Controlpanel --> administrative tools --> Service --> select the MSSQLSERVER –> right click go to properties –> log on tab –>
log on as this account –> key in  domain\administrator user and give password. Apply, Restart the MSSQLSERVER SErvice

Step 2 :

Open the Enterprise Manager –> expand the database server tree on the left pane –> navigate to the Support Service folder --> SQL mail --> right click and select properties –> PRofile name : you can see OUTLOOK by default and all the profiles created on the machine using Microsoft Exchange Server/ used in outlook. Select the OUTLOOK or the profile you want to use to send email from sql server, in the Profile name. Click Test to check the email is sent to the selected profile email id. Close the dialog box.

(Note : if you are not able to see any profiles in the Proflie Name section, it means your MSSQLSERVER is not running under the same windows NT account as the email profile you want to use for sql server mail)

Step 3 :

Open the Enterprise Manager –> expand the database server tree on the left pane –> navigate to the Management Folder –> Check whether Sql server Agent is running or not, if not right click and select Start. –> expand Sql Server Agent and select Operators –> Right click Operators –> select New operator –> Give Name of the operator in the Name field –> select Email to be notified on the action like success or failure of a job.  (click … button to open the Outlook AD address book ) –> click Test button to send the test email to the selected email id. Click OK to close the dialog box.

Step 4:

While still in Management folder tree in Enterprise Manager select Jobs under the Sql Server Agent –> Right click jobs, select New Job , on General Tab give Job Name, let the category and owner be default, if you r scheduling Stored procedure. –>

Go to Steps Tab, click on New button to create a new Step, in Name textbox, give the name of Step viz. Step1. In Type Dropdown, select Transact Sql Script - T-Sql, in Database Dropdown select the appropriate Database where you have saved the SP. In the Command section give the Stored procedure to execute. (e.g. Exec SpMyFirstSchedule (with parameters if any)) or give the system command to perform any system task. Click on the Advanced Tab, give path to Output file, the job will save the resultset of the SP at the given path, if any. Click OK to close the Step Dialog box. Now, you are back to Jobs dialog box. 

--> select the third tab, called schedule tab –> click New Schedule button, give Schedule name in the dailog box that opens, and select the schedule when you wnat the job to automatically execute. you have option of executing it once, or every week or when the system is idle or everytime when sql server agent starts. Click OK to close the dialog box. now you are back to Jobs dialog box.

--> select the forth tab, Notifications. Select the Email Operator Check box and select the operator we created just now (refer Step 3). You can Choose to send the notification when the Job completes, either when the job is successful or when job fails.  If it is a one time job, you can select the checkbox to delete the job as soon as it is successful. End of step 4.

Alternatively You can also send the detailed email to the stake holders from the stored procedure itself, using master.dbo.xp_sendmail.

if you get the errors described below, the solution can be achived if you carefully follow the steps given.

Related Errors:

Solution : Error 22022: SQL Server Agent Error: The SQL Server Agent Mail Session is not Running;Check the mail profile and/or
the SQL Server Agent Service Startup account in the SQL
Server Agent Properties Dialog.

Refer following links for other similar articles.

http://www.mssqlserver.com/articles/sqlmail_p1.asp

http://support.microsoft.com/?id=263556

Happy programming.

Read more!

Saturday, March 21, 2009

How to Create Charts in Asp.Net 2.0 using Microsoft Chart .Net 3.5

Hi,

Today, I would like to share my view on how to create chart in Asp.net 2.0. As we all know traditionally microsoft asp.net didnt had support for Charts from its own factory. But, after Microsoft Took over Dundas chart, Microsoft is providing the Drag and Drop Chart functionality for visual studio 2008 or .Net framework 3.5.

To start with, You will need to download the Following  :

Microsoft .Net Framework 3.5

Microsoft .Net Framework 3.5 SP1

Microsoft Chart for .Net 3.5

You will need to install them in the order mentioned. Because the Chart control is a part of .Net Framework 3.5 SP1.

Once the installation is done, you are ready to create stunning Charts in Asp.net without using any third party tool.

Step 1: Create a New Website in Visual Studio 2005.

Step 2: Look for a Chart Control in the Toolbox. Drag and drop it to proceed. (if you are not able to find chart control, right click toolbox Add tab, give it a name Chart. Right click Chart Tab –> Add Items, Browse to Program Files –> Microsoft Chart controls –> Assemblies –> System.Web.DataVisualization.dll. Once you add this dll, you will have chart control in your toolbox)

Step 3: Add SqlDataSource and configure it to Northwind database and the simple query as shown in the image below.

datasource

Step 4: Click on the Smart tag of Chart control and select SqlDataSource1 for the Datasource.

Step 5: Now lets do some basic configuration. there are basically 2 important properties you need to know to start creating Charts in Asp.net 2.0

1) ChartAreas: Click the (…) button next to ChartAreas in property window of Chart1. Change the Property values related to Appearance of the chart like its background color, to suit your website color themes.

->  Locate the Axis Property in the ChartArea Collection Editor, click on the (…) button to open the Axis collection editor, Select X Axis from the left pane, and select Title property from the right. Type in ‘Countries’ in Title property

-> Select Y (value) Axis from left pane and select Title from right pane, enter ‘Count’ in Title Property. Click OK to clost the window.

-> Select Axis Property from left pane, find X Axis, LabelStyle Section, Modify the Angle Property to –90 and Interval to 1, This is required to display all the values in X axis.

2) Series: Select the Chart control, from properties, select Series property and click on (…) button to open up the Series Collection Editor.

-> In the left pane Series1 will be selected by default, now select X Value Member property from right pane, and select the appropriate column name coming from database. In our case select ‘country’.

-> Again, Select Y Value Member property in right pane and select ‘Count’ column.

That is it, We are ready to display the chart, before we execute it, let me tell you about the 3D view of the Chart. Select the ChartAreas Property collection, Look for Area3DStyle in the right pane, expand it by clicking on the + sign and set (Enable3D) to True. This will help us to display the chart in 3D angle.

This is how it look likes when you run it.

column

 

And ya, to change the chart to any other format you like just follow simple step,

-> Select Series collection from property window, Select different chart type from ChartType property, see the image below to get better idea.

charttype

 

Below are the few types of chart we can create using Microsoft Chart control.

Bubble

bubble

 

Doughnut

doughnut

Pyramid

pyramid

I hope i have done justice to this article, my next article will discuss about some common errors you may face as a beginner to Chart control.

Do comment if you have any doubts.

Happy programming

Source : Here

Read more!

Friday, March 13, 2009

Solution to The conversion of a char data type to a datetime data type resulted in an out-of-range datetime

Hi,

I would like to share my opinion on one of the problems i faced while working with datetime format in Asp.net 2.0 and sql server 2000 on windows server 2003.

I encountered an error 'The conversion of a char data type to a datetime data type resulted in an out-of-range datetime'. while trying to save a date to the datetime column in database.

The Reason : Sql server supports the datetime format depending upon the regional datetime setting of the database server. so if your development server supposet MM/dd/yyyy , not necessarily your production or testing database server will support the same format. As a result you might have done coding to save it in a particular format & the same code may not work on another server.

Solution : After trying various things i came to a conclusion the best way to handle this error is to have precautionary steps while dealing with them.

Consider a case, where you just want to store the date.. without timestamp. as sql server doesnt have any specific date format you need to save the date in datetime dtatype column in database.
You can first create a stored procedure with the insert statement

CREATE PROCEDURE [dbo].[spInsert_]
@dt datetime
AS
BEGIN
Insert into IDtable (dt) values (@dt);
GO
END

Now call the above stored procedure from front end asp.net 2.0 code.

Dim dt As DateTime = DateTime.Now.ToString("yyyy-MM-dd")
MyCmd.Connection = MyCon
MyCmd.CommandType = Data.CommandType.StoredProcedure
MyCmd.CommandText = "spInsert_"
MyCmd.Parameters.Add("@dt", SqlDbType.DateTime)
MyCmd.Parameters("@dt").Value = dt
MyCmd.Transaction = trans
Dim res As Integer = MyCmd.ExecuteNonQuery()

Here, I would like to point out, the universal format supported by sql server is yyyy-MM-dd hh:nn:ss where nn is minutes...

so if you make a practice of storing your data in the said format, you will never encounter this error...

second important thing is to use Store Procedure with parameters, you can just pass the date value as parameter to store procedure, it will do the necessary casting.

Other solution :
SET DATEFORMAT dmy
before executing any sql statement. (i havent tried this one)

Source : http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/095eb7a7-222a-4a15-8301-2a2acca2ca3f/

if you find my article useful, do leave a comment.

Cheers,
happy programming
Idu

Add to Technorati Favorites Read more!

Wednesday, March 4, 2009

error The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' while asp.net 2.0, crystal report 10 deployment

Hi,

I have developed a web application using Asp.net 2.0, Crystal report 10, Ajax, Sql server 2k.
Crystal report work fine on development machine. but once i tried to deploy it in production environment ( windows server 2003, iis 6.0).

I came across following error while executing the Crystal report on production server

error The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument'.

after googling it for quite some time.. i came across one of the post on msdn forum.

The solution is :

Open the asp.net 2.0 web application to be deployed in visual studio 2005

Add New project -> select the Setup and deployment from left pane and WebSetup from right pane.

click on the setup project and then click on properties.

From there click on the prerequisite button.

Check Crystal Reports for .Net Framework 2. (and other necessary dependencies like MDAC 2.8)

I then selected download prerequsites from the same location as my application.

Rebuild the setup project.

Go to the WebSetup Project folder, you will find CRRedist2005_x86.msi file under CrystalReport Folder (under Release or Debug folder, which ever u selected prior to building the websetup) .

I ran this CRRedist2005_x86.msi file on the Production machine and it worked like charm

I hope it helps.
Cheers
Happy Programming
Source : msdn.microsoft.com

Add to Technorati Favorites Read more!