Server Error in '/' Application.

Conversion failed when converting the nvarchar value '15746-' 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 '15746-' to data type int.

Source Error:


Line 5:      var nID =Request.QueryString["PNID"].ToString();
Line 6:      var mID=nID.Right(nID.Length-1);
Line 7:      var Title=db.QueryValue("select newsTitle from nmg_news where Id=@0",mID);
Line 8:      Title=Title.Replace(" ","-");
Line 9:                         Title=Title.Replace(".","");

Source File: c:\inetpub\Host\mazandnume.com\www\rcLayouts\_rcMazandnume-01.cshtml    Line: 7

Stack Trace:


[SqlException (0x80131904): Conversion failed when converting the nvarchar value '15746-' to data type int.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +3329424
   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) +4289
   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.SqlClient.SqlCommand.CompleteExecuteScalar(SqlDataReader ds, Boolean returnSqlValue) +52
   System.Data.SqlClient.SqlCommand.ExecuteScalar() +371
   WebMatrix.Data.Database.QueryValue(String commandText, Object[] args) +130
   ASP._Page_rcLayouts__rcMazandnume_01_cshtml.Execute() in c:\inetpub\Host\mazandnume.com\www\rcLayouts\_rcMazandnume-01.cshtml:7
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +99
   System.Web.WebPages.WebPage.ExecutePageHierarchy() +185
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +122
   System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +327
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +123
   System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +88
   System.Web.WebPages.WebPageBase.PopContext() +349
   System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +142


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