.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

error in in converting

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net

I developing small project using N-Tier Architecture. I added dbml to my project ie., linq to sql. I wrote properties to my project

namespace MovieLibrary{

public class Movie:IMovie
       public int id { get; set; }
       public string mname { get; set; }
       public string dname { get; set; }


In Business Logic Layer I am accessing like this.

namespace DataAccessObject
    public class DataAccess
        public List<Movie> GetMovie()
            List<Movie> listmovie = new List<Movie>();
            MovieDataContext db = new MovieDataContext();
            listmovie = from m in db.movies
                        select m;
            return listmovie;

View Complete Post

More Related Resource Links

Error converting data type varchar to numeric.


I create a form to record data using ASP.NET and SQL database...
when i run the project show error "Error converting data type varchar to numeric"

what's the problem actually.i try to change in datatype in database..
but still showing error...


Error in SharePoint Designer when converting to XSL

While using SharePoint Designer, I attempt to convert a web part "list view"  to XSL and i get the error:  "The server returned a non-specific error when trying to get data from the data source.  Check the format and content of your query and try again.  If the problem persists, contact the server administrator."  Was able to convert this same web part a week ago, and now I am getting this error.  I have restarted all of the servers and still receive this error.  The only thing I can think of is that there might be an issue with having too much data in the list.  Any ideas?

Error converting data type nvarchar to numeric.

i create a form using form view tools in asp.net..when i click insert command it shows error..this is code which i use for InsertCommand:<asp:SqlDataSource ID="SqlDataSourceFormView" runat="server"         ConnectionString="<%$ ConnectionStrings:AED_PanasonicConnectionString2 %>"         SelectCommand="SELECT * FROM [Debtor]"        InsertCommand="INSERT INTO Debtor (CompanyName, Desc2, RegisterNo, Address1, Address2, Address3, Address4, PostCode)VALUES (@CompanyName, @Desc2, @RegisterNo, @Address1, @Address2, @Address3, @Address4, @PostCode)">        </asp:SqlDataSource>Error:-Error converting data type nvarchar to numeric.where i have to make changes?

Arithmetic overflow error converting expression to data type smallint

Can anyone tell me what exactly this means? Arithmetic overflow error converting expression to data type smallint. 

error converting nvarchar to int

i have two multivalue paramaters in a report and when I try to select more that one value for the results then i get this error when rendering the rpt both paramaters are int in the value field but I am displaying the label in the screen of the selection and passing the value as into the sproc.   it works with only one value

Error converting data type nvarchar to datetime.

hi all, I simply explain my application.plz try to understand. In my applicationi want to generate one complaint id.one customer may give two or more complaints at a time.suppose,he give two or more pnr numbers and their status and prioirty may differs.for this complaint i need to generate one common complaint id.how it is possible..?with some constant rows. am getting error in Class File near CLUser_Logged_DTClass File using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Web.Configuration; /// <summary> /// Summary description for BalComplaints /// </summary> public class BalComplaints { public BalComplaints() { // // TODO: Add constructor logic here // } int SNo, Complaint_Type_ID, Caller_Type_ID, No_of_Articles, Article_ID, CLPriority_ID, Status_ID, Origin_ID, Destination_ID; public int SNo1 { get { return SNo; } set { SNo = value; } } public int Caller_Type_ID1 { get { return Caller_Type_ID; } set { Caller_Type_ID = value; } } public int Destination_ID1 { get { return Destination_ID; } set { Destination

Error converting data type varchar to numeric



I am trying to execute below query.



CAST('123,456,789.00' AS DECIMAL(11,2))

SQL error: Conversion failed when converting date and/or time from character string.

I hope someone can advise on the issue I'm having.

This SQL worked beautiful until I added in @startdt and @enddt and this section >> AND [Selldate] BETWEEN ' + @startdt + ' AND ' + @enddt + '

By adding in this condition, I now get the following error:

Msg 241, Level 16, State 1, Line 8
Conversion failed when converting date and/or time from character string.

I have tried changed variables to type = date and various iterations of date formatting, casting with no success. The date in the table is clean as a whistle.

(The CONVERT function is being used in setup for a PIVOT SQL which needs  VARCHAR for column headers)

Thanks in advance for your help, 

declare @itemID varchar(20)
declare @startdt varchar(12)
declare @enddt varchar(12)
set @itemID = ''

Error converting data type nvarchar to numeric in Store Procedure execution



When I execute a Store Procedure via 'EXEC sp_XXX @p1, @p2' I'm getting this error 'Error converting data type nvarchar to numeric'.

After diggin into the TSQL code I have found that there's a field (type: nvarchar(200)) breaking the execution and resulting on the error.

If I query the table and the specified field with the same parameters as the Store Procedure the results are ok! If I execute the same code as the Store Procedure with the same parameters values the results are ok. The error only happens when executing the Store Procedure.

Any idea ?

Thanks in advance,

Gustavo Brian


If I cast the field to a smaller size value, as nvarchar(80), it works, but of course with data truncation.


"IN" operator and error converting data type varchar to numeric



I hope someone can help me figure this out please...

I have this query that returns some student data - specifically the student's names, and some classes they're enroled in. What I'm trying to do is return multiple rows using the LIKE operator.

However when I run it and plug in the parameters I get the errror - "Error converting data type varchar to numeric". This error doesn't occur when there is only ONE studentId. Only when there are multiple studentIds. I know it's to do with the string of studentIds being passed, but I'm not sure how to fix it?

Should I be using varchar as the datatype to pass the studentIds? Or do I need to cast this as something else?

Any ideas, much appreciated.



	@StudentIds varchar(8000),
	@ProfileId numeric,
	@Fname varchar(50) OUTPUT,
	@Lname varchar(50) OUTPUT,
	@ClassName varchar (100) OUTPUT,
	@ClassName2 varchar (100) OUTPUT,
	@ClassName3 varchar (100) OUTPUT,
	@ClassName4 varchar (100) OUTPUT,
	@Class numeric OUTPUT,
	@Class2 numeric OUTPUT,
	@Class3 numeric OUTPUT,
	@Class4 numeric OUTPUT


@Fname = Fname, @Lname = Lname, @ClassName = C.ClassName, @ClassName2 = C2.ClassName, @ClassName3 = C3.ClassName, @ClassName4 = C4.ClassName,

Error converting data type varchar to numeric in SQL SERVER

Hi frendz..
Demo Example is...

alter FUNCTION [dbo].[Return_Example] 
@a numeric(18,4),
@b numeric(18,4)
RETURNS numeric(18,4)
@division numeric(18,4),
@reminder numeric(18,4),
@Num2 varchar(100),
@c numeric(18,4)

set @division=floor(@a/@b)
set @reminder=@a%@b
----Here output will be a concatenated
set @Num2= cast((@division +'.'+ @reminder) as numeric(10,3)) 
set @c=cast(@Num2 as numeric(18,3))


Execute :

exec Return_Example 50 ,5



i m facing the Problem for this getting an error like this


pls clear my error


CREATE PROCEDURE [dbo] . [UserDepositDetails_SPIns]

-- Add the parameters for the stored procedure here ( @regid int ,


Error while converting XSD to .cs file


Hi All,

Getting error while converting a XSD file to .cs by running the command xsd member.csd /c

Schema validation warning: Type 'http://schemas.microsoft.com/sqlserver/2004/sqltypes:bigint' is not declared. Line 6, position 10.
Schema validation warning: Type 'http://schemas.microsoft.com/sqlserver/2004/sqltypes:varchar' is not declared, or is not a simple type. Line 9, position 14.

Please help me out to resolve this issue. Thanks in Advance..

Here is XSD Schema

<xsd:schema xmlns:schema="Member" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes" targetNamespace="Member" elementFormDefault="qualified">
  <xsd:import namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes" schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd" />
  <xsd:element name="Member">
        <xsd:element name="Member_ID" type="sqltypes:bigint" />
        <xsd:element name="FirstName" minOccu

System.Data.SqlClient.SqlException: Error converting data type nvarchar to datetime.


 Hi All,

I have recently moved a ASP.NET webserver from windows XP to
windows server 2008.
The website runs fine apart from anywhere that pulls a date
or uses the date from a JS date picker etc.

The error I am receiving is:

System.Data.SqlClient.SqlException: Error converting data type nvarchar to datetime.

Source Error:

Line 79:         cmd1.Parameters.AddWithValue("@EndDate", lblSearch2.Text);
Line 80:         conn.Open();
Line 81:         SqlDataReader reader = cmd1.ExecuteReader();
Line 82:         if (reader.HasRows)
Line 83:         {

Source File: c:\inetpub\wwwroot\folderx\pagex.aspx.cs    Line: 81

Stack Trace:

[SqlException (0x80131904): Error converting data type nvarchar to datetime.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1951450
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849003
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject s

Syntax error converting varchar value to a column od data type int


Hi everyone,

I'm having a problem where I've created a stored procedure with a dynamic ORDER BY clause and it's returning a syntax error:

Server: Msg 245, Level 16, State 1, Procedure usp_OrderBy, Line 4

Syntax error converting the varchar value 'Closed' to a column of data type int.

Here is the code that I'm trying to execute. It works fine if I take out the ID line:

CREATE PROCEDURE [Task_User].[usp_OrderBy]
  @orderBy varchar(100)
  SELECT ID, Status, PostedBy, Assigned, Subject
  FROM mainTable
    WHEN @orderBy = 'ID' THEN ID --When I take this out, it works
    WHEN @orderBy = 'Status' THEN Status
    WHEN @orderBy = 'PostedBy' THEN PostedBy
    WHEN @orderBy = 'Assigned' THEN Assigned
    WHEN @orderBy = 'Subject' THEN Subject
Any ideas as to what I can do to fix it?

Arithmetic overflow error converting expression to data type int.


I have a table with a row called row1, this row1 is a bigint and has values from 0  To  4278190080


I am running a query such as: select top 1 * from tableA where row1 <= (((73*256+62)*256+53)*256 + 12)


How can I get this to work? I tried to do where cast(row1 as float) <= ....... but I get the same error.

Error converting data type nvarchar to int


I've got a very simple report (using Employees table in Northwind) that I'm using an INT (EmployeesID) as the parameter. (Query Failed for Dataset1)

it works fine if I choose only one item from the list - but I'm allowing Multiple values, but when I actually choose multiple values, I get the error that's in the subject line.

My sProc to get the Employees from the ManagerID (which is actually the EmployeeID - list of employees) .Here's the code:


Select Emp.EmployeeID,
.Firstname +

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend