Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 1st, 2008, 12:13 PM
Authorized User
 
Join Date: May 2007
Location: , , United Kingdom.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASp.NET with C#, Chapter 8

Hi
On page 267 when I try to update a record in the DetailsView control I get this error message

"The data types text and nvarchar are incompatible in the equal to operator.
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: The data types text and nvarchar are incompatible in the equal to operator."

Any advice on why this isn't working and how I fix it?

Many thanks
Judy

  #2 (permalink)  
Old February 2nd, 2008, 07:12 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Judy,

Can you post the relevant pieces of code for this?

You get this error when your database contains a Text column, and your code thinks it's an nvarchar column, or vice versa. Only by looking at the relevant code and database schema can we provide useful suggestions.

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #3 (permalink)  
Old February 5th, 2008, 11:18 AM
Authorized User
 
Join Date: May 2007
Location: , , United Kingdom.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is my page:

<%@ Page Language="C#" MasterPageFile="~/site.master" AutoEventWireup="true" CodeFile="Fixtures.aspx.cs" Inherits="Fixtures" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="Server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="FixtureID"
        DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
        <Columns>
            <asp:CommandField ShowSelectButton="True" ShowEditButton="True" ShowDeleteButton="True" />
            <asp:BoundField DataField="FixtureID" HeaderText="FixtureID" ReadOnly="True" SortExpression="FixtureID" />
            <asp:BoundField DataField="FixtureDate" HeaderText="FixtureDate" SortExpression="FixtureDate" />
            <asp:BoundField DataField="FixtureType" HeaderText="FixtureType" SortExpression="FixtureType" />
            <asp:BoundField DataField="GoalsFor" HeaderText="GoalsFor" SortExpression="GoalsFor" />
            <asp:BoundField DataField="GoalsAgainst" HeaderText="GoalsAgainst" SortExpression="GoalsAgainst" />
            <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" />
            <asp:BoundField DataField="Opponents" HeaderText="Opponents" SortExpression="Opponents" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:WroxUnitedConnectionString %>"
        ProviderName="<%$ ConnectionStrings:WroxUnitedConnectionString1.Prov iderName %>"
        SelectCommand="SELECT [FixtureType], [FixtureID], [FixtureDate], [GoalsFor], [GoalsAgainst], [Notes], [Opponents] FROM [Fixtures]" DeleteCommand="DELETE FROM [Fixtures] WHERE [FixtureID] = @FixtureID" InsertCommand="INSERT INTO [Fixtures] ([FixtureType], [FixtureDate], [GoalsFor], [GoalsAgainst], [Notes], [Opponents]) VALUES (@FixtureType, @FixtureDate, @GoalsFor, @GoalsAgainst, @Notes, @Opponents)" UpdateCommand="UPDATE [Fixtures] SET [FixtureType] = @FixtureType, [FixtureDate] = @FixtureDate, [GoalsFor] = @GoalsFor, [GoalsAgainst] = @GoalsAgainst, [Notes] = @Notes, [Opponents] = @Opponents WHERE [FixtureID] = @FixtureID">
        <DeleteParameters>
            <asp:Parameter Name="FixtureID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="FixtureType" Type="String" />
            <asp:Parameter Name="FixtureDate" Type="DateTime" />
            <asp:Parameter Name="GoalsFor" Type="Int16" />
            <asp:Parameter Name="GoalsAgainst" Type="Int16" />
            <asp:Parameter Name="Notes" Type="String" />
            <asp:Parameter Name="Opponents" Type="String" />
            <asp:Parameter Name="FixtureID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="FixtureType" Type="String" />
            <asp:Parameter Name="FixtureDate" Type="DateTime" />
            <asp:Parameter Name="GoalsFor" Type="Int16" />
            <asp:Parameter Name="GoalsAgainst" Type="Int16" />
            <asp:Parameter Name="Notes" Type="String" />
            <asp:Parameter Name="Opponents" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="FixtureID"
        DataSourceID="SqlDataSource2" Height="50px" Width="450px" DefaultMode="Insert">
        <Fields>
            <asp:BoundField DataField="FixtureID" HeaderText="FixtureID" InsertVisible="False"
                ReadOnly="True" SortExpression="FixtureID" />
            <asp:BoundField DataField="FixtureDate" HeaderText="FixtureDate" SortExpression="FixtureDate" />
            <asp:BoundField DataField="FixtureType" HeaderText="FixtureType" SortExpression="FixtureType" />
            <asp:BoundField DataField="GoalsFor" HeaderText="GoalsFor" SortExpression="GoalsFor" />
            <asp:BoundField DataField="GoalsAgainst" HeaderText="GoalsAgainst" SortExpression="GoalsAgainst" />
            <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" />
            <asp:BoundField DataField="Opponents" HeaderText="Opponents" SortExpression="Opponents" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:WroxUnited %>"
        SelectCommand="SELECT [FixtureID], [FixtureDate], [FixtureType], [GoalsFor], [GoalsAgainst], [Notes], [Opponents] FROM [Fixtures]"
        ConflictDetection="CompareAllValues"
        DeleteCommand="DELETE FROM [Fixtures] WHERE [FixtureID] = @original_FixtureID AND [FixtureDate] = @original_FixtureDate AND [FixtureType] = @original_FixtureType AND [GoalsFor] = @original_GoalsFor AND [GoalsAgainst] = @original_GoalsAgainst AND [Notes] = @original_Notes AND [Opponents] = @original_Opponents"


        InsertCommand="INSERT INTO [Fixtures] ([FixtureDate], [FixtureType], [GoalsFor], [GoalsAgainst], [Notes], [Opponents]) VALUES (@FixtureDate, @FixtureType, @GoalsFor, @GoalsAgainst, @Notes, @Opponents)"
        OldValuesParameterFormatString="original_{0}"
        UpdateCommand="UPDATE [Fixtures] SET [FixtureDate] = @FixtureDate, [FixtureType] = @FixtureType, [GoalsFor] = @GoalsFor, [GoalsAgainst] = @GoalsAgainst, [Notes] = @Notes, [Opponents] = @Opponents WHERE [FixtureID] = @original_FixtureID AND [FixtureDate] = @original_FixtureDate AND [FixtureType] = @original_FixtureType AND [GoalsFor] = @original_GoalsFor AND [GoalsAgainst] = @original_GoalsAgainst AND [Notes] = @original_Notes AND [Opponents] = @original_Opponents">
        <DeleteParameters>
            <asp:Parameter Name="original_FixtureID" Type="Int32" />
            <asp:Parameter Name="original_FixtureDate" Type="DateTime" />
            <asp:Parameter Name="original_FixtureType" Type="String" />
            <asp:Parameter Name="original_GoalsFor" Type="Int16" />
            <asp:Parameter Name="original_GoalsAgainst" Type="Int16" />
            <asp:Parameter Name="original_Notes" Type="String" />
            <asp:Parameter Name="original_Opponents" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="FixtureDate" Type="DateTime" />
            <asp:Parameter Name="FixtureType" Type="String" />
            <asp:Parameter Name="GoalsFor" Type="Int16" />
            <asp:Parameter Name="GoalsAgainst" Type="Int16" />
            <asp:Parameter Name="Notes" Type="String" />
            <asp:Parameter Name="Opponents" Type="String" />
            <asp:Parameter Name="original_FixtureID" Type="Int32" />
            <asp:Parameter Name="original_FixtureDate" Type="DateTime" />
            <asp:Parameter Name="original_FixtureType" Type="String" />
            <asp:Parameter Name="original_GoalsFor" Type="Int16" />
            <asp:Parameter Name="original_GoalsAgainst" Type="Int16" />
            <asp:Parameter Name="original_Notes" Type="String" />
            <asp:Parameter Name="original_Opponents" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="FixtureDate" Type="DateTime" />
            <asp:Parameter Name="FixtureType" Type="String" />
            <asp:Parameter Name="GoalsFor" Type="Int16" />
            <asp:Parameter Name="GoalsAgainst" Type="Int16" />
            <asp:Parameter Name="Notes" Type="String" />
            <asp:Parameter Name="Opponents" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>

  #4 (permalink)  
Old February 5th, 2008, 02:23 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

In what tables (and for what columns) are you using the text data type? Does the book instruct you to use those types? (That is, is the table correct and does it line up with the code you need to write?)

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET 1.1 with VB.NET 2003 chapter 1 subroger Wrox Book Feedback 2 November 11th, 2004 12:52 PM
Beg. ASP.Net eCommerce with VB.Net - Chapter 5 James Hendrix All Other Wrox Books 0 October 22nd, 2003 10:45 PM
Errors in Chapter 1?? ASP.NET 1.0 with VB.NET jaksel BOOK: Beginning ASP.NET 1.0 2 August 18th, 2003 01:02 AM



All times are GMT -4. The time now is 05:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.