Wednesday, August 24, 2016

How to compare Time only from the current date in C#

Following is the time comparison in 24 hour format

DateTime dt = DateTime.Parse(DateTime.Now.ToString ());

String strTime = dt.ToString("HH:mm");

if (strTime == System.Configuration.ConfigurationManager.AppSettings["ExecTime"].ToString())
{
// Matches
}

Or

if (strTime == “13:30”)
{
// Matches

}

Windows Search Service will not start, Error: "The Windows Search service on local computer started and then stopped. Some services stop automatically if they are not in use by other services or programs" – In C#, Windows service

Solution 1

Start - Run - then Type Services.msc and click enter button now you will get all the services in your computer after that select your service and right click on that and go to Properties
Then open Select Log On tab and then select Local System Account and click Ok
Restart your service

Solution 2

Check the framework version of the developed machine and the framework in the deployed machine

<startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>

Solution 3


Probability of this could be from the wrong configuration of project installer in the application, you will have to create a new project and copy the complete file except Project Installer. Configure the project installer once again 

Could not establish trust relationship for the ssl/tls secure channel with authority c# ASP.Net - Web service

In C#

System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return true; };

In VB.Net

System.Net.ServicePointManager.ServerCertificateValidationCallback = 
Function(senderX, certificate, chain, sslPolicyErrors)
Return True
End Function


Add this line just before calling the Web service method, issue will be solved  

Wednesday, November 21, 2012

Cannot load data source sybase , cannot open file c:\sybase\OLEDB\ .ids

HI Folks,

Error : Cannot load data source sybase , cannot open file c:\sybase\OLEDB\ .ids

Weird error, I got really confused by seeing this error. Finally, I got a solution for this J

 Solution

Please have a look on to the Connection string in the web.config file, if you have given the provider name differently you will have to change to  Sybase.ASEOLEDBProvider.2

<add key="ConnStringSYB" value="Provider=Sybase.ASEOLEDBProvider.2;Server Name=servername,portno if any; Initial Catalog=dbname;User Id=id;Password=password"/>

This is most important, please check the provider name it will work

Provider=Sybase.ASEOLEDBProvider.2

Saturday, September 29, 2012

Unable to start debugging on the web server. the project is not configured to be debugged

I lost my mind by searching a solution for this since I need to work on VS 2003/2005/2010 web solution, End up with above error many times and it has wasted my precious time. I do not want the same happening to anyone.


Please give the priority that is marked with High

Solution 1 [High] : Go to Inet Manager select the web site that’s created for the application, in the property select the tab ASP.NET and choose the ASP.NET version then click Ok and the most importantly you will have to do the same exercise for Default Web Site (Select the Default web site -> Property -> Select ASP.NET tab -> Choose ASP.NET version), Both should have same version.

I guess the above solution will work for many

Solution 2 [Medium]: IIS should be configured to use in Integrated Windows Authentication ( Inet manager -> Select the web site created for the application -> Properties -> Select the Directory Security Tab -> Under the Anonymous access and Authentication Control click EDIT -> make sure that check box is ticked for Integrated Windows Authentication.

There are other solutions for the above error I will post it depends on your feedback 

Sunday, September 16, 2012

Error : Year, Month, and Day parameters describe an un-representable DateTime

Error : Year, Month, and Day parameters describe an un-representable DateTime

Well, I had stuck with above error and hardly wasted my half day time.

Solution 1 : You have to check the system date format ( Go to Command prompt type "Date") and SQL server date format (Type select getdate() in the Query window) format, if the system date format differs please change it according to the SQL server format.


Solution 2 : Use the below code format

string dt= DateTime.Now.ToString("MM/dd/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo);

And then save the "dt" to the database.
The code is shown below.
       string dt= DateTime.Now.ToString("MM/dd/yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo);
       Response.Write(dt);
       SqlConnection conn = new SqlConnection("server=.;database=Test;uid=sa;pwd=issac");
       conn.Open();
       SqlCommand cmd = new SqlCommand("insert into test(dtime) values(@dt)", conn);
       cmd.Parameters.Add("@dt", SqlDbType.DateTime);
       cmd.Parameters[0].Value = dt;
       cmd.ExecuteNonQuery();
       conn.Close();
Recommendation (Not in all case, depends) : It would be a good practice to have date selection from the SQL server itself 

Wednesday, September 12, 2012

there was a problem getting an app domain to run the transformation from the host. the process cannot continue

there was a problem getting an app domain to run the transformation from the host. the process cannot continue

Solution for this problem 



  1. 1) Try removing <NetFx40_LegacySecurityPolicy enabled="true" /> line from the devenv.exe.config file which is located "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE"
  2. Try restarting the VS 
  3. 3) Install the SP1 for VS 2010 

Third point worked for me but for my colleagues its 1st and 2nd. Try any one of the solution sure it works for you as well 

Good day