Wednesday, April 22, 2015

Steps to configure crystal reports in published site in IIS

Steps to configure crystal reports in published site in IIS

1. Add Handler

Request Path - CrystalImageHandler.aspx
Type :- CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304
Name :- CrystalImageHandler.aspx_GET

In Request restrictions
Deselect Invoke handler option.


2. Web.Config

In System.web , httphandlers section

<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />

In System.Webserver, handlers section

<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode" />

3. Run msi for crystalreports

CRRedist2008_x64

4. In VS design open crystal report verify database, republish.

Monday, April 20, 2015

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.


SOLUTION / FIX : 

the 64-bit framework dlls weren’t able to 32-bit versions of the 'Microsoft.ACE.OLEDB.12.0' provider modules.

If you are running Visual Studio on a 64-bit machine, IIS 7 is not (by default) serving 32-bit applications.

However, the database engine operated on 32-bit.

Follow these steps to fix the issue:

1.    Open the IIS 7.5 manager and select the application pool corresponding to your web application.
2.    Right click the application pool and select ‘Advanced settings’.
3.    Select the field ‘Enable 32-bit applications’ and change it to 'true'.
4.    Restart your application pool and access your application to fix the error you saw.



Monday, April 13, 2015

No mapping exists from object type System.Web.UI.WebControls.

I am getting the the message on the command:

commandObj.ExecuteNonQuery();

Complete message is:

No mapping exists from object type System.Web.UI.WebControls.TextBox to
a known managed provider native type.



Solution: its actually a very silly mistake 

Seems as if  you set the DataBinding on the TextBox/Label itself instead of the Text property of the TextBox/Label?

for Example: 

cmdInsert.Parameters.Add(new SqlParameter("@LastName", txtLastName));

Instead of
cmdInsert.Parameters.Add(new SqlParameter("@LastName", txtLastName.Text));

Wednesday, April 8, 2015

Send Email from Yahoo!, GMail, Hotmail (C#)

Server Parameters

Server NameSMTP AddressPortSSL
Yahoo!smtp.mail.yahoo.com587Yes
GMailsmtp.gmail.com587Yes
Hotmailsmtp.live.com587Yes

Sample Code

using System.Net;
using System.Net.Mail;
string smtpAddress = "smtp.mail.yahoo.com";
int portNumber = 587;
bool enableSSL = true;
string emailFrom = "fromEmailID@yahoo.com";
string password = "yourEmailPassword";
string emailTo = "someone@domain.com";
string subject = "Testing Email ";
string body = "Hello, I'm sending Email via Code ..." ;
using (MailMessage mail = new MailMessage())
{
    mail.From = new MailAddress(emailFrom);
    mail.To.Add(emailTo);
    mail.Subject = subject;
    mail.Body = body;
    mail.IsBodyHtml = true;
 
    mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
    mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));
    using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
    {
        smtp.Credentials = new NetworkCredential(emailFrom, password);
        smtp.EnableSsl = enableSSL;
        smtp.Send(mail);
    }
}