Friday, August 16, 2013

How to solve CS0433 compile error?

I got the CS0433 compile error when I tried to run my web application project, error occurred due to the user control I have.

The error message:
Compiler Error Message: CS0433: The type 'usercontrolname' exists in both 'c:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\root\f331a27e\ffbf5479\App_Web_udkg0wsp.dll' and 'c:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\root\f331a27e\ffbf5479\App_Web_hqhnzr3p.dll'

I encountered this error before, and my solution was to delete the files in temp folder manually. I was thinking if there's another better solution for this. Finally, I've found the solution.

Just set the batch="false" attribute on the compilation section in web.config.

       <compilation debug="false" batch="false"></compilation>

This tells ASP.NET to dynamically compile individual .aspx/.ascx files into separate assemblies. This avoids the circular reference issue that triggers the exception.

I got this solution from here.

Monday, March 18, 2013

Error installing NuGet

I was trying to install NuGet, and I got this error.
Then I realized that I have installed NuGet before. When I tried to click on the "Update" button for the NuGet, I got the same error too.
After doing some research, finally I have found this is a known issue, and it's documented in NuGet  docs.
I just installed the Visual Studio 2010 SP1 hotfix and the problem is solved!

Just go here to solve the problem - Known issues with NuGet.

Wednesday, January 30, 2013

Hide all buttons in listview

I was looking for how I can hide all buttons in listview, by calling a function, without needing to populate data to the listview again (not using the ItemDataBound event).

Here's the solution I've found, it's so simple!

private void ShowButtons(bool show)
        foreach (ListViewItem item in lvwQuotations.Items)
            ((Button)item.FindControl("btnView")).Visible = show;

Thursday, January 10, 2013

First calling SELECT statement in mySql

It may be simple, but I did not know the syntax of doing so, hence I have also spent some time to get this done. Well, finally it works!

ArrayList parameters = new ArrayList();
parameters.Add(new OdbcParameter("?Email", email));
parameters.Add(new OdbcParameter("?Password", password));
string sql = "SELECT * FROM Members WHERE Email=? and Password=?";

First attempt to connect to mySql database with ASP.NET

After a few day researching and trying, finally I've successfully connect to mySql database with ASP.NET.
I really gotta write down how to do so, otherwise I'll surely forget the steps even in near future.

I have WAMP server installed, (learn how to set up WAMP server here) at first I was working with the mysql already installed with WAMP.
I tried to connect to the database, but failed to do so, I always got "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified" when I was trying to call Connection.Open().
I have been searching around, but couldn't find the solution yet, and I suspected it was something wrong with my mysql setting, then I decided to install mysql separately.

These are how it helped me to work:

1. First, I downloaded MySQL Community Server 5.5.29, the latest version, zip edition, but I couldn't understand how it worked.
Then I clicked on "Looking for previous GA versions?", downloaded & installed MySQL Community Server 5.1.67.
I just revisited the page now, and now only I found there is a recommended download - MySQL Installer 5.5 for Windows (All MySQL Products - including MySQL server, connectors, Workbench, etc), perhaps I should get this.

2. Then, I got the MySQL Workbench, which is a GUI tool, to help me easily work with the database.
After setting all these, I still get the "Data source name not found" error.

3.Finally, I found this - Setting up MySQL for use through ODBC. This really saved me! And I managed to connect to mysql database successfully!

This is the connection string I use:
DRIVER={MySQL ODBC 5.1 Driver};SERVER=localhost;PORT=3306;DATABASE=test;UID=root;PWD=;