Posts

Showing posts from July, 2013

Donate

Error 1064 Insert Statement Using MySQL Parameters In C#

Good evening! The code above has a database field called desc which is a reserved word in SQL as an order by criteria. dbQuery = String.Format( @"INSERT INTO accom_temp_hotelagencies(hotel_id, agency_id, hotel_webid, desc)VALUES(?HotelId, ?AgencyId, ?HotelWebId, ?Description)" ); The solution is to enclose the field name desc with an acute or back quote. as shown in the code below: dbQuery = String.Format( @"INSERT INTO accom_temp_hotelagencies(hotel_id, agency_id, hotel_webid, `desc`)VALUES(?HotelId, ?AgencyId, ?HotelWebId, ?Description)" ); Cheers!

LINQ Slow Performance In Checking Almost 1 Million Or Large Data (Optimization Problem) In C#

I have a code below which returns an object after satisfying a given condition. 1 2 3 result = listCountryStateCollection.Find(e => (e.CountryName.ToLower().Trim() == accomTempHotel.CityProvinceCountryName[0].CountryName.ToLower().Trim()) && (e.StateName.Trim().ToLower() == accomTempHotel.CityProvinceCountryName[0].StateName.ToLower().Trim()) && (e.SuburbCityName.Trim().ToLower() == accomTempHotel.CityProvinceCountryName[0].SuburbCityName.ToLower().Trim())); The problem I encountered was that, it was slow in getting the desired results. After doing optimization/code checking I came up with a simple solution. The solution is not to include string manipulations in your LINQ but instead the processing should be done using variables as defined below: 1 2 3 4 5 6 string country = accomTempHotel.CityProvinceCountryName[0].CountryName.ToLower().Trim(); string state = accomTempHotel.CityProvinceCountryName[0].StateName.ToLower().Trim(); string s

Debugging jQuery Or Javascript Code Not Working In ASP.NET MVC 3 (VS 2010)

In my MVC 2 post here: Debuggin jquery/javascript code , the workaround was to isolate the javascript codes in a separate .js file. However, there's another way to add breakpoints by referring to localhost html file in the solutions explorer as stated in this website link: Debuggin javascript with IE9/Visual Studio 2010 MVC 3 Greg

ASP.NET MVC C# Razor Syntax Quick Reference

Here's a quick reference of razor syntax with webforms equivalent: http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx Cheers!

Donate