tags:

views:

221

answers:

1

Why i get this error:

The data types text and nvarchar are incompatible in the equal to operator. The field of "username" in database is text type...

This is my soruce:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="my_answers.ascx.cs" Inherits="kontrole_login_my_answers" %>

<div style=" margin-top:-1280px; float:left;">       

<p></p>


                              <div id="question">
Add question





</div>
</div>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" 

   >

</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:estudent_piooConnectionString %>" 
    SelectCommand="SELECT * FROM [question] WHERE ([username] = @fafa)">
    <SelectParameters>
        <asp:QueryStringParameter Name="fafa" QueryStringField="user" 
            Type="String"/>
    </SelectParameters>
</asp:SqlDataSource>
A: 

"text" is used for really large text fields and in modern versions of SQL Server shouldn't even be used (replaced by varchar/nvarchar(max) ) With text (and image) column types in SQL server, you have a small subset of operations you can actually use.

Whoever created a username field of type "text" did not know what they were doing, and it will cause you all kinds of limiting problems until you can change it to something more sane.

Joe