Posts

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!

WebService Is Undefined Error In ASP.NET 4.0

1. First step is to add reference to the web service using Ajax Script Manager: <asp:ScriptManager ID= "ajaxManager" runat= "server" > <Services> <asp:ServiceReference Path= "~/Services/ProductService.asmx" /> </Services> </asp:ScriptManager> 2. Secondly is to include the namespace in calling the webservice method From ProductService.GetProducts( function (data) { $.each(data, function (index, elem) { $( "<option />" ) .text(elem.ProductName) .val(elem.ProductID) .appendTo( "#products" ); }); } ); To AccessingServerSideDataUsingClientScript.Services.ProductService.GetProducts( function (data) { $.each(data, function (index, elem) { $( "<option />" )

Example Of IsPalindrome Generic Function Using Queue In C#

Hello, Excerpt from .NET 4.0 Generic's Guide , there's an example on testing whether a string is Palindrome using a Stack<T> object. I decided to create a a Queue<T> based method. One additional tip was to reverse the Queue object. See sample function below: public static bool IsPalindromic<T>(IEnumerable<T> inputSequence) where T : IComparable { Queue<T> buffer = new Queue<T>(); foreach (T element in inputSequence) { buffer.Enqueue(element); } buffer = new Queue<T>(buffer.Reverse()); for ( int i = 0; i < inputSequence.Count(); i++) { if (buffer.Dequeue().CompareTo(inputSequence.ElementAt(i)) == 0) { continue ; } else return false ; } return true ; } Source Code: Example Of IsPalindrome Generic Function Using Queue In C# That

OpenWebKitSharp Document Text Similar To .NET WebBrowser In C#

Here's how you get the page source of a WebKitBrowser similar to DocumentText property of a .NET WebBrowser Control. JSValue val = webkitBrowser.GetScriptManager.EvaluateScript( "document.getElementsByTagName(\"html\")[0].outerHTML;" ); if (val != null ) { PageSource = val.ToString(); } Greg

How To Set Attribute Option Element In OpenWebkitSharp C#

Here's how you set option element attribute using OpenWebKitSharp. foreach (WebKit.DOMNode optionElement in nodeItem.ChildNodes) { if (searchInnerHtml && optionElement.TextContent.Equals(searchInnerString)) { WebKit.InteropIDOMHTMLElement el = (WebKit.Interop.IDOMHTMLElement)optionElement.GetWebKitObject(); el.setAttribute( "selected" , "selected" ); } }

Retrieving the COM class factory for component with CLSID {D6BCA079-F61C-4E1E-B453-32A0477D02E3} Openwebkitsharp3.0

If you encountered an error while running OpenWebkitSharp in your workstation or production server with the specific details below: Retrieving the COM class factory for component with CLSID {D6BCA079-F61C-4E1E-B453-32A0477D02E3} failed due to the following error: 800736b1 The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. (Exception from HRESULT: 0x800736B1). The solution is to download Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update here: Visual C++ 2005 Service Pack 1 Redistributable and install it in your server/workstation. Greg

GeckoFX How To Trigger Or Fire JavaScript _doPostBack() Method

Here's how you fire a _doPostBack() in ASP.NET using GeckoFX. //fire js method using (AutoJSContext context = new AutoJSContext( this .JSContext)) { string result; context.EvaluateScript( string .Format( "javascript:__doPostBack('{0}','')" , paramControlName), out result); } Cheers!

Donate