Server Error in '/' Application.

Conversion failed when converting the nvarchar value 'BX_Inductive_Proximity_Sensor_Switch' to data type int.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting the nvarchar value 'BX_Inductive_Proximity_Sensor_Switch' to data type int.

Source Error:


Line 51:     var subLink = UrlData[0];
Line 52:     var subHead = subLink.Replace("_", " ");
Line 53:     var row = dbProducts.QuerySingle("SELECT * FROM stock WHERE id=@0", id);
Line 54:     bool codeRequired = row.codeRequired;
Line 55:     if (row == null)

Source File: c:\inetpub\vhosts\automationbros.com.au\httpdocs\Product.cshtml    Line: 53

Stack Trace:


[SqlException (0x80131904): Conversion failed when converting the nvarchar value 'BX_Inductive_Proximity_Sensor_Switch' to data type int.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +3335264
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +334
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4679
   System.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows) +255
   System.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more) +298
   System.Data.SqlClient.SqlDataReader.Read() +43
   System.Data.Common.DbEnumerator.MoveNext() +54
   WebMatrix.Data.<QueryInternal>d__22.MoveNext() +280
   System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source) +209
   ASP._Page_Product_cshtml.Execute() in c:\inetpub\vhosts\automationbros.com.au\httpdocs\Product.cshtml:53
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +99
   System.Web.WebPages.WebPage.ExecutePageHierarchy() +191
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
   System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +142


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4700.0