Sunday, July 29, 2012

ASP.NET - Sorting Dataset


How to Sorting "DataSet" value in ASP.NET C#


DataSet dsList = new DataSet();

 OleDbDataAdapter da = new OleDbDataAdapter(sqlStr, conn);
 da.Fill(dsList);

dsList.Tables["FIU.CASES_MASTER"].DefaultView.Sort = "CREATE_DATE";

DB2 Date format in Select Query


How to convert 'dd-mon-yyyy' date format to db2 date format


Solution:

Syntax:
select to_Char(field name,'MM/DD/YYYY') from table name

Monday, July 23, 2012

ASP.NET - Arabic Text Insert Problem in DB2

arabic text insert problem in asp.net

i have a problem with inserting arabic texts in SQL Server or DB2 or Oracle
everytime i insert arabic text  , it changes autmatically to ??????? ,

Solution

SQL Server:

Datatype should be nvarchar
And your INsert & Update Query should be like this

INSERT INTO TABLENAME(FirstName,LastName) VALUES (N'Gowri',N'Shankar')


DB2 & ORACLE:

connectionString="Provider=DB2OLEDB;User ID=xxxxxx;Initial Catalog=APPLDB;Network Transport Library=TCPIP;Host CCSID=28596;PC Code Page=28596;Network Address=xxx.xxx.xx.xx;Network Port=50000;Package Collection=DB2COLLECTION;Default Schema=jdbc;Connect Timeout=15;Units of Work=RUW;DBMS Platform=DB2/MVS;Defer Prepare=False;Rowset Cache Size=0;Max Pool Size=100;Persist Security Info=False;Connection Pooling=True;Derive Parameters=False;Password=xxxxxxxxx"

web config file

<system.web>
    <globalization requestEncoding="ISO-8859-6" responseEncoding="ISO-8859-6" />

Tuesday, July 17, 2012

ASP.NET - Send Email with Attachment

Send Email 

with Attachment

with CC

with HTML body

 

using System.Net.Mail;

try
        {
            MailMessage mail = new MailMessage();
            SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
            mail.From = new MailAddress("reports@moi.gov.sa");
            mail.To.Add("gowri.utham@esolutionsroad.com");
           mail.CC.Add("gowri.utham@gmail.com");
            mail.Subject = "Trial Report - MOI Portal Registrations & Transactions - Daily Stats - " + DateTime.Now.ToString("dd/MM/yyyy");
            mail.IsBodyHtml = true;
            mail.Body = "<html><body>Dears,<br><br>Please find portal registration and transaction statistics in detail as of <b> " + DateTime.Now.ToString("dd/MM/yyyy") + " </b>.<br><br>Thanks,<br><br>Biz Dashboard Opz Team.</body></html>";

            System.Net.Mail.Attachment attachment1;
            attachment1 = new System.Net.Mail.Attachment(@"C:\Users\gowri\Desktop\StatisticsReport.pdf");
            mail.Attachments.Add(attachment1);

            System.Net.Mail.Attachment attachment2;
            attachment2 = new System.Net.Mail.Attachment(@"C:\Users\gowri\Desktop\TransactionReport.pdf");
            mail.Attachments.Add(attachment2);

            SmtpServer.Credentials = new System.Net.NetworkCredential("user name", "password");

            SmtpServer.Port = 25;
            SmtpServer.Host = "xxx.xxx.xxx.xxx";
           

            SmtpServer.Send(mail);
            Response.Write("Mail has been Send");
            Response.Write(DateTime.Now.ToString("dd/MM/yyyy HH:mm:s"));
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }

Wednesday, July 11, 2012

ASP.NET Web Service - The test form is only available for requests from the local machine


If you simply open the web config file and add the following, you will be able to access the test form outside of the localhost:


<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>

Tuesday, July 10, 2012

Error : The Configuration section cannot be used at this path. Your Current Security setting do not allow this file to be download.



Error : The Configuration section cannot be used at this path. Your Current Security setting do not allow this file to be download.




The Configuration section cannot be used at this path.This happens when the section in locked at a parent level. Locking is either by default(OverrideModeDefault="Deny"), or set exactly by a location tag with OverrideMode="Deny" or the legacy allowOverride="false"?

Error : The Configuration section cannot be used at this path. Your Current Security setting do not allow this file to be download.

Solution:
Open the applicationHost.config file

C:\WINDOWS
SYSTEM32\INETSRV\CONFIG\APPLICATIONHOST.CONFIG

And Change AllowOverride="true" instead of false on that file.

Error : Session state can only to be used when enable sessionState is set to True


Error : Session state can only to be used when enable sessionState is set to True




Session state can only to be used when enable sessionState is set to True, either in configuration file or in the page directive. Please also make sure the System.Wbe.SessionStateModule or a custom SessionState modle is included in the <configuration>\<system.web>\<httpModule>.

Solution :
Step : 1
 <page enableSessionState="true">.
Step : 2
<modules runAllManagedModulesForAllRequests="True" >.

Step : 3
remove the line if available
<modules>
           <remove name="session" />
</modules>

How to Install VSTA (Visual Studio Tools for Applications)


I was searching for an installer for VSTA (Visual Studio Tools for application).

Solution :
Control Panel ---> Add or Remove Program --> Office 2007 -- > Change -- > Add or remove features

Under Microsoft Info Path  Visual Studio Tools for application and Choose Run as My Computer. Continue.
After successful completion restart your computer.

InfoPath 2010 Contact Selector Control. Unable to add

This contol cannot be added through the custom control wizard. To use this control, go to the controls gallery on the home tab.

Solution:
In Infopath 2010 already exist. the control Called Peopl/Group Picker. You can add this control and set Sharepoint server.

If you want same problem in Infopath 2007 use this link.
http://blogs.msdn.com/b/infopath/archive/2007/02/28/using-the-contact-selector-control.aspx

ASP.NET Error : section registered as allowDefinition='MachineToApplication' beyond application level.


Error : 
"It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. 
This error can be caused by a virtual directory not being configured as an application in IIS. "


Solution:
1. Instead or Virtual Directory create Application   i.e. add your project as "Application" in IIS.
2. Check the Application Pools in IIS. 
3. Compare Your project version and Application Pool version.
4. Now you can run you project.

How to configure Authentication in IIS

This is a step for asking Authentication at each time of running your website from IIS.
You can follow these step for Enable or Disable Authentication in IIS.
 
You want like this Popup window or you want to avoid this popup window, you can follow these steps.

Step 1:
Go to the Authentication tab. Double Click it.



Step 2 :

If you want show Authentication popup window you should enable Windows Authentication is Enabled and Anonymous Authentication should be Disabled and
you want to hide the Authentication popup  
you should Disabled Windows Authentication and Anonymous Authentication should be Enabled.