Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2007, 05:43 AM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data type mismatch

Hi all,

I am trying to create a connection for the datareader to access the database but seem to be getting a series of errors when trying different alternatives. At the moment I seem to be getting one particular error of Data Type Mismatch. Please see the following code: -

    Sub BindShoppingBasket

        DBConnection = New OleDbConnection ( _
            ConfigurationSettings.AppSettings("ConnectionStrin g"))
        SQLString = "SELECT * FROM ShopBasket INNER JOIN Products " & _
            "ON ShopBasket.ItemNumber = Products.ItemNumber " & _
            "WHERE OrderNumber = '" & Session("OrderNumber") & "' " & _
            "ORDER BY ShopBasket.ItemNumber"

        DBCommand = New OleDbCommand(SQLString, DBConnection)
        DBConnection.Open()
        DBReader = DBCommand.ExecuteReader()
        ShoppingBasket.DataSource = DBReader
        ShoppingBasket.DataBind()

        DBConnection.Close()

        If OrderTotal > 0 Then
            ChangeOrderMessage.Visible = True
            CustomerID.Value = Session("OrderNumber")
            OrderAmount.Value = FormatNumber(OrderTotal, 2)
        End If

        DateOut.Text = Today
        OrderOut.Text = Session("OrderNumber")
        CustomerID.Value = Session("OrderNumber")

    End Sub

Does anyone have any suggestions on how I get round this error or explain why this keeps happening.
Thanks
Sharon


 
Old May 21st, 2007, 12:29 AM
Friend of Wrox
 
Join Date: Aug 2006
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

man check the datatype of "OrderNumber" in ur database..
if it's a number remove the extra two ( ' ) from you command on the where condition..

Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
 
Old May 27th, 2007, 10:01 AM
Registered User
 
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Many thanks for the suggestion the OrderNumber was set to Number in the Database so have removed the extra '' out of the code and is now working wonderfully.

Thanks
Sharon






Similar Threads
Thread Thread Starter Forum Replies Last Post
data type mismatch karma SQL Language 3 April 6th, 2006 07:58 AM
Getting Data Type mismatch for autonumber somissac General .NET 4 March 1st, 2006 12:02 AM
Data type mismatch problem dominic_huang Classic ASP Databases 3 November 15th, 2004 03:12 AM
Data Type mismatch error clueless_may Access VBA 1 May 5th, 2004 09:16 AM
Data Type Mismatch error transcona Classic ASP Databases 4 June 25th, 2003 07:23 PM





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