Can not log on locally to as user x with virtual directory password

If you look close at the error, it will say Module : IIS Web Core This means it is coming from IIS. The problem is you do not have permission to access the config file. The error actually quotes config file as well, esp the line that says

Resolution Go to the location where your config file is located. The IIS should give you that location in the error message. Right click in the folder and check directory permission. See what permission user ‘x’ has. In my case, somehow it has a cross sign on top of it. I…

Read More

Fix ASP.NET Menu Layout Issue in Chrome and Safari

I had this menu issue which would not render properly in Chrome and Safari but run ok in Internet Explore and FireFox. The following is the fix. Put the following code at the top of your Page_load() function of the page where the issue exists. /* Fix the Chrome and Safari Menu layout issue (ASP) */ if (Request.UserAgent.IndexOf("AppleWebKit") > 0) { Request.Browser.Adapters.Clear(); } I copied this originally from somewhere. Can’t seem to find it.

Read More

Reading null values from datatabase in C# code

If you tried reading a null value from the database such as a null date, you might have across this exception Specified cast is not valid Casting Nullable Values The following code works unless a null datetime is returned. Note that DateTime is followed by ? which means this date can accept a null value therefore nullabe. /* assume nullable datetime in the database */DateTime? exportDate = null;exportDate = (DateTime)cmd.ExecuteScalar(); This is a little bit strange that you cannot use DateTime? operator to cast the return value as a nullable datetime. Although you can use it and it will not…

Read More

Condition on null does not work with =

What do you expect from the following code? Will the block inside if be executed? IF ( @ID != NULL )   BEGIN       UPDATE inventory       SET    count = 5       WHERE  id = @ID   END  The statments inside If will never be executed because it will always evaluate false. The reason it equal (=) operator is not compatible with NULL. To compare NULL value, use IS operator. To fix the above we can write IF ( @ID IS NOT NULL )   BEGIN       UPDATE inventory       SET    count = 5       WHERE  id = @ID   END  Or we can use ISNULL operator to convert NULL into a value IF ( Isnull(@ID, 0) = 0 )   BEGIN       UPDATE inventory       SET    count = 5       WHERE  id = @ID   END 

Read More

Object reference not set to an instance of an object.

How to troubleshoot Object reference not set to an instance of an object in C#. Put a break point in the code, execute the code Inspect the value where you are getting this error Inspect the value you are assigning to a variable/object or inspect the object itself that is being assigned the value open the watch1 widow (Dubug>Windows>Watch>Watch1), type in the variable exactly as it appears in code with the dot.  Are you getting a value for the field? Are you getting nullreference exception instead? If so there is where the exception is coming from. It is possible that…

Read More

Database Vendor code: 229 – Crystal Report

If you get the below error in Crystal Report Failed to retrieve data from the database. Details: [Database Vendor Code: 229] This mean you do not have access to the data. This possibly occurred because you created your report on one machine and then deployed it on another. On deployment, you noticed that your report does not pull that data instead you get this error. The most likely cause is the permission. You do not have permission to query that data or run stored procedures or function. Possible Causes Your report uses functions calls or store procedure, your login is…

Read More

Force GridView to Refresh in ASP.NET

You can force gridview to referesh its data by calling GridViews.DataBind() function in the code behind.

I have also come across a couple of others solutions that does the same. The one that works best is to use databind() on gridview This is the most elegant solution. As an example, lets say you have a GridView that displays data from a table. You have another FormView that inserts data into the gridview. If you insert the data from FormView, you will notice that gridview does not updates the data. To fix this, select the FormView, go to properties, create…

Read More

Weird ASP Bug – Gridview update does not work if there is somethign in page_load function

In my Gridview, select, insert, delete all were working properly but not Update. Found out that my code in Page_load() was causing this not to work. I removed the code from page load where I as updating the Gridview. The update started working again. What is weird is there was no error and no indication where the problem was. You have to hunt all possible avenues to hunt for the error.

Read More

Weird ASP.NET Error – Insert does not work in FormView in ASP.NET

You have a FormView and an Insert Template inside it, if you put the insert template fields in an ASP.NET table for better formatting, the insert function will not work. This is very weird. In the above example, the fields in table … will not work. The culprit here is runat=”server”. If you remove this, the insert works. … rows and cells This is quite a weird error in ASP.NET. But the following works

Read More

wordpress theme not displaying properly

You just installed a wordpress theme and when you activated it (or even previewed it), it does not show properly. It takes the whole page, there is only html contents, no formatting is applied. This happened to me when I installed my new template. Interesting it worked on my local system but did not work on my public domain. I troubleshooted this using Firefox Developer Plugin. If you have already installed it, you can right click in the page, in the popup menu go to Web Developer > CSS > View CSS This will show all your CSS files in…

Read More