ADO.NET :: The Data Types Ntext And Nvarchar Are Incompatible In The Equal To Operator - How To Avoid This Error

Mar 16, 2011

I've found a lot of similar topics but none of them solves my problem.

I have table structure like that


Everyone suggests to change ntext type to nvarchar(MAX) and life will be beautyfull. But... First, I need
ntext, simply because there should be text in this field.

nvarchar(MAX) equals 4096 bytes which is to small for large text. Second, I already have table with
ntext field, which does not cause this error.

View 2 Replies

Similar Messages:

ADO.NET :: Getting Error - The Data Types Text And Varchar Are Incompatible In The Equal To Operator?

Nov 10, 2010

So admitingly I am fairly new at .NET...I have been a PHP guy for rather long time...

Heres my code:


Essentially what I am trying to do is query the SQL database by the username. This above code is a method within the user respository for fetching a user by their username. The variable "username" is passed in as a string.

When the method is called a recieve the following error:

The data types text and varchar are incompatible in the equal to operator.

This to me is rather confusing since the field in the database, user_username, is a text and the variable passed in, as said, is a string. They should be synonomous for all practical purposes.

Ideas? Thoughts? Fixes?

View 2 Replies

Data Types Text And Varchar Are Incompatible In The Equal To Operator?

Dec 4, 2010

Here is the code:


Dim intusercount As Integer = 0
Using connection As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True")
Using command As New SqlCommand("SELECT [ID] FROM [Members] WHERE [Username]=@Username AND [Password]=@Password", connection)
command.Parameters.Add("@Username", Data.SqlDbType.VarChar).Value = TextBox1.Text
command.Parameters.Add("@Password", Data.SqlDbType.VarChar).Value = TextBox2.Text
intusercount = command.ExecuteScalar
If intusercount > 0 Then
End If
End Using
End Using

The data types text and varchar are incompatible in the equal to operator.

Source Error:

Line 11: command.Parameters.Add("@Password", Data.SqlDbType.VarChar).Value = TextBox2.Text
Line 12: connection.Open()
Line 13: intusercount = command.ExecuteScalar
Line 14: connection.Close()
Line 15: If intusercount > 0 Then


[SqlException (0x80131904): The data types text and varchar are incompatible in the equal to operator.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +2030802
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5009584
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
System.Data.SqlClient.SqlDataReader.get_MetaData() +86
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +311
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +987
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteScalar() +139
_Default.Button1_Click(Object sender, EventArgs e) in C:UsersUserDocumentsVisual Studio 2010WebSitesWebSite13Default.aspx.vb:13
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

View 2 Replies

DataSource Controls :: Data Types Text And Varchar Are Incompatible In The Equal To Operator?

Jul 4, 2010

I get the following error: The data types text and varchar are incompatible in the equal to's my code (PageName is a string Parameter) :

SqlConnection sql = SQLconnection();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Select title, text, postdate, sticky from articles where pagename = @pagename;";

View 2 Replies

WebMatrix :: Does Not Change Column Type From Nvarchar To Ntext

Aug 20, 2010

Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

View 1 Replies

DataSource Controls :: SQL Server Does Not Handle Comparison Of NText, Text / Xml Or Image Data Types

May 24, 2010

I have a bit of code in a clickevent handler like this:-

Dim products = From p In db.Products where p.product_name = "Tool" Select New With {p.Product_ID,p.Product_name}
Gridview1.Datasource = products

But causes error=SQL Server does not handle comparison of NText, Text, Xml, or Image data types?

where product_name field is set as type text

View 1 Replies

SQL Server :: Operand Type Clash: Nvarchar Is Incompatible With Image?

Mar 6, 2011

My table contains a column named visitorimage with image as the datatype. I have a stored procedure to insert an image but whenever I try to create the sp an error occurs saying"Operand type clash: nvarchar is incompatible with image". What's the problem and how to fix this?

ALTER PROCEDURE [dbo].[usp_addvisitor] @lastname nvarchar(50), @firstname nvarchar(50), @visitorimage image, @gender char(6), @personalid nvarchar(50), @vehicleno nvarchar(20), @company nvarchar(50), @represent nvarchar(100), @phonenumber bigint, @mobilenumber
bigint, @address nvarchar(100), @remarks nvarchar(200) AS INSERT INTO tblVisitor VALUES (@lastname, @firstname, @visitorimage, @gender, @personalid, @vehicleno, @company, @represent, @phonenumber, @mobilenumber, @address, @remarks)

View 3 Replies

C# - All Queries Combined Using A UNION, INTERSECT Operator Must Have An Equal Number?

Jan 7, 2010

I have a linq to sql query where I have to perform union two set of records.

And I do not have equal number of fields, so added the null

eg my psuedo code is


after googling some hours I came to understand that it is bug in 3.5 framework.

Now I want to retrieve the result.

How do I do thatI tried framing into two seperate iqueryable

var a= first query

var b =second query

ilist result =a.union b

This too results in the same error.

View 3 Replies

.net - Two Incompatible Session State Types In ASP.NET?

Mar 27, 2011

I see two means of working with session data in ASP.NET MVC:

System.Web.SessionState.HttpSessionState, available on HttpApplication
System.Web.HttpSessionStateBase, available on Controller

Data stored in one seems to be available in the other. Unfortunately the only common ancestor of these two types is System.Object, meaning that I can't create reusable utility code for the abstraction of either.Why is the API this way? Is there an important difference between the two that I am missing?

View 1 Replies

Error Converting Data Type Nvarchar To Float / How To Fix It

Nov 30, 2010

Here is the code:


After I try to test the page, I am getting the following error:


[b]Error converting data type nvarchar to float. [/b]


View 1 Replies

Syntax Error Converting The Nvarchar Value To A Column Of Data Type Int?

May 5, 2010

I have 1,2,3,4,5,6,7,8,9 stored as nvarchar inside Level in my db.

I then have a dropdownlist with values 1,2,3,4,5,6,7,8,9. When a user makes a selection (i.e 1) (Level.SelectedValue.ToString). This builds an sql query via a param like this:

"Select things From MBA_EOI Where level = 1"

When I run the select I get the following error:

Syntax error converting the nvarchar value '1,2,3,4,5,6,7,8,9' to a column of data type int.

I was under the impression that I was dealing with an Nvarchar field and the selected value as string, where does the int conversion come in?

p.s I have also tried Level.SelectedItem.ToString

View 1 Replies

DataSource Controls :: Error Converting Data Type Nvarchar To Int?

Jan 6, 2010

when i am trying to uedit my recods in gridview this error is coming. I am using SQLDatasource with gridview and for edit purpose i am using stored procedure. I have manually executed the SP and its woring fine. my SP is here


and my SQLDataSource is here


and gridview is here


View 2 Replies

Data Controls :: SQL Error / Conversion Failed When Converting Nvarchar Value To Data Type Int

May 7, 2015

how can in sql server show two columns as one column.. one of them is nvarchar  and the other is int from two tables i have did this but it give error

select depart.depart_name+input_comp.no_of_depart as department,dbo.depart.depart_id from dbo.depart inner join dbo.input_comp on dbo.depart.depart_id=dbo.input_comp.depart_id group by depart.depart_name,dbo.depart.depart_id,input_comp.no_of_depart
the depart_name is nvarchar datatypeand the no_of_depart is int datatype

the error is

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

View 1 Replies

Data Controls :: Error Converting Data Type Nvarchar To Bigint C#

Jan 24, 2016

I'm getting the following error base on dropdownlist selectindexchanged: error converting data type nvarchar to bigint

Below is my dropdownlist code:

Protected Sub ddlTaxName_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlTaxName.SelectedIndexChanged
Dim strConnString As String = ConfigurationManager.ConnectionStrings("BytConnectionString").ConnectionString()
Dim strQuery As String = "select TaxName, [Rate(%)] from Sale_Tax where" & " TaxID = @TaxID"
Dim con As New SqlConnection(strConnString)

[Code] .....

View 1 Replies

Data Controls :: Error Converting Data Type Nvarchar To Numeric

Nov 6, 2013

protected void Update(object sender, EventArgs e)
foreach (GridViewRow row in gvStudeff.Rows)


View 1 Replies

SQL Server :: Error: Conversion Failed When Converting The Nvarchar Value ' ' To Data Type Int

Mar 28, 2011

I have a query in SQL Server 2008:


Everything looks fine but I keep getting the error: 'Conversion failed when converting the nvarchar value 'xxxx' to data type int... where xxxx is the the value of @Query.

View 3 Replies

SQL Server :: Error Converting The Nvarchar Value '1,2,3,4,5,6' To A Column Of Data Type Int - IN Where Clause

Feb 28, 2011

I am using an adapter to get a list with IN where clause as:


I passed the parameter, CatIDList, with string value 1, 2, 3, 4, 5

However, it returns error of Error converting nvarchar value.

View 3 Replies

Data Controls :: Saving DropDownList Value To Database - Error Converting Data Type Nvarchar To Int

May 7, 2015

I am using  a  viewstate to store the company Ids and splitting at hyphen.

protected void onCompanychange(object sender, EventArgs e) {
ViewState["companyID"] += companydropdown.SelectedValue + "-";
String companyids = ViewState["companyID"].ToString();
string pattern = "-";
company_array = Regex.Split(companyids, pattern);
company_length = company_array.Length;

Company array is a string array  where i have stored the company ids

the problem is company_array[0] has the initial value of the dropdownlist(company) --select company which is why m getting the error(cannot convert data type nvarchar to int) .  I have used the same logic in many places in my project it did not give any error.

int count = 0;
company_length = company_length - 1;
while (count < GridView3.Rows.Count && compid_counter < company_length ) {
cmd = new SqlCommand("insertWorkDetais", conn);
cmd.CommandType = CommandType.StoredProcedure;

[Code] .....

View 1 Replies

Forms Data Controls :: Getting Error - CS0019: Operator '/' Cannot Be Applied To Operands Of Type 'object' And 'int'

Jul 21, 2010

I am moving a website to a new framework. But the old site is in vb and the new on I'm coding it in C#.

I have this line of code that I can't figure out, This is on the aspx page. It's in a datagrid as well.


The line that is messing up is the second to last one where it starts with </a>(<%#Math.Round....

Here is the error I get...CS0019: Operator '/' cannot be applied to operands of type 'object' and 'int'

I've tried to work around it but can't fix this

View 4 Replies

Configuration :: Web App Error: An Address Incompatible With The Requested Protocol Was Used?

Apr 3, 2010

I am encountering an error when attempting to log into a web app (via a login page) on one of my servers. The web app is an IMAP4 client under development that should connect to the mail server currently running on the same machine. I am successful at connecting to the mail server from my development workstation running an IMAP4 desktop client under similar development.The error is... An address incompatible with the requested protocol was usedThe login page works fine in my development environment on my local workstation (connecting to the local mail server). A little research suggests the error has something to do with IPv4 vs IPv6 addressing, but I'm not sure. I have 2 network adapters in this server, for each of which IPv6 is not enabled. I have successfully reset the TCP/IP stack on the server (netsh Winsock reset) but still the error returns. Only one of the adapters is enabled and being used.

View 4 Replies

SQL Server :: Operand Type Clash : Int Is Incompatible With Xml Error?

Feb 15, 2011

Following Query giving error, Please let me know whats prevent from getting this error.

declare @EmployeeID int
set @EmployeeID = 454655
SET @XMLCONTENT = N'<EmployeeID> <Data ID="'+ CONVERT(nvarchar(100),@EmployeeID) +'"/> </EmployeeID>'

View 3 Replies

ADO.NET :: Change Nvarchar(4000) To Nvarchar(50) With EF 4.0 With Out The Designer

Nov 8, 2010

I would like to know, how to set up the Entity framework to create a nvarchar(50) insted of a nvarchar(4000), when creating a string? by the way I am not using the designer!

View 6 Replies

DataSource Controls :: Regarding Size - Nvarchar(100) Vs Nvarchar(50)

Mar 25, 2010

Does it make a difference in terms of the actual size of the database if I define one of the columns as nvarchar(100)? If there are restrictions on the form as for how much you can input, let's say 50 characters, does the db save blank spaces from character 51-100 and create a database that is larger than it would be it the column was defined as nvarchar(50)?

View 2 Replies

SQL Server :: Convert Label.text To Int / Error Conversion Failed When Converting The Nvarchar Value 'Label' To Data Type Int.'?

Jul 14, 2010

I have been messing about with this for hours surely this should be an easy task ....... I have a stored procedured that creates a invoice on a Quotetable one of the parameters is a output parameter Invoice Number this is passed to a label. (Label1) This works great.

I then need to add items to the invoice on a item table so my next stored procedure should take the value of Label1 and update the foreign key quotenumber on the itemtable with the value from label1.

On the aspx page I have a small section for a gridview which shows the current quote with however many items on it using the control


On the ASP page the control for @Quotenumber = Label1 but I get the following error

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

View 3 Replies

Error In Converting Datatype Nvarchar To Bigint?

Oct 1, 2010

this code is giving me error:

error in converting datatype nvarchar to bigint this is my table values:

@customer_first_name nvarchar(50),
@customer_last_name nvarchar(50),
@customer_address nvarchar(max),
@gender nchar(10),
@date_of_birth datetime,
@customer_email_id varchar(50),
@customer_occuption varchar(50),
@customer_phone_number Bigint,
@nominee_name nchar(50),
@customer_id nvarchar(50),
@account_type nvarchar(50),
@account_number nvarchar(50),
@transfer_access_code nvarchar(50),
@account_balance Bigint,
@pin_code BigInt,
@nationality nvarchar(50),
@password nvarchar(50)
lblAmount.Text = HFamount .Value ;
int balamount = Convert.ToInt32(lblAmount.Text);
int Cpincode = Convert.ToInt32(txtpincode.Text);
long phone = Convert.ToInt64(txtphone.Text);
string cust_id = CUSTOMER_ID_GENERATOR();
string strconstring = ConfigurationManager.ConnectionStrings["ONLINE_BANKING2_ConnectionString"].ConnectionString;
SqlConnection mycon = new SqlConnection(strconstring);
SqlCommand cmdRegister= new SqlCommand(sqlquery,mycon);
cmdRegister.Parameters.Add(new SqlParameter("@customer_first_name",txtcustname.Text.ToString()));
cmdRegister.Parameters.Add(new SqlParameter("@customer_last_name",txtcustlastname.Text.ToString()));
cmdRegister.Parameters.Add(new SqlParameter("@customer_address",txtAddress.Text.ToString()));
cmdRegister.Parameters.Add(new SqlParameter("@gender", rbtngender.SelectedItem.Value.ToString()));
cmdRegister.Parameters.Add(new SqlParameter("@date_of_birth", txtDOB.Text));
cmdRegister.Parameters.Add(new SqlParameter("@customer_email_id", txtemail.Text.ToString()));
cmdRegister.Parameters.Add(new SqlParameter("@customer_occuption", txtcustoccupation.Text.ToString()));
cmdRegister.Parameters.Add(new SqlParameter("@customer_phone_number", phone));
cmdRegister.Parameters.Add(new SqlParameter("@nominee_name", txtnominee.Text.ToString()));
cmdRegister.Parameters.Add(new SqlParameter("@customer_id", cust_id));
cmdRegister.Parameters.Add(new SqlParameter("@account_type", accType.SelectedItem.Value.ToString()));
cmdRegister.Parameters.Add(new SqlParameter("@account_number", ACCOUNT_NUMBER_GENERATOR()));
cmdRegister.Parameters.Add(new SqlParameter("@transfer_access_code",Transfer_code()));
cmdRegister.Parameters.Add(new SqlParameter("@account_balance", balamount));
cmdRegister.Parameters.Add(new SqlParameter("@pin_code", Cpincode));
cmdRegister.Parameters.Add(new SqlParameter("@nationality", DropCountry.SelectedItem.Value.ToString()));
cmdRegister.Parameters.Add(new SqlParameter("@password",txtpasswd2.Text.ToString()));

View 1 Replies

Copyrights 2005-15, All rights reserved