Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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 November 15th, 2005, 06:27 PM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to webgen
Default DataType Mismatch

Can anyone tell me why I am getting a data type mismatch error on the following code?

Sub DoItemDelete(objSource As Object, objArgs As DataListCommandEventArgs)

   Dim strConnect As String = ConfigurationSettings.AppSettings("DsnWroxBooksJet ")

   Dim strDelete As String
   strDelete = "DELETE * FROM Authorizations WHERE AuthID='" _
          & MyDataList.DataKeys(objArgs.Item.ItemIndex) & "'"

   Dim objConnect As New OleDbConnection(strConnect)

   objConnect.Open()

   Dim objCommand As New OleDbCommand(strDelete, objConnect)
   objCommand.ExecuteNonQuery()

   objCommand = nothing
   objConnect.Close()
   objConnect = nothing





   'create a suitable SQL statement and execute it
   'Dim strSQL As String
   'strSQL = "DELETE * FROM Authorizations WHERE AuthID='" _
    ' & MyDataList.DataKeys(objArgs.Item.ItemIndex) & "'"
   'ExecuteSQLStatement(strSQL)

   'set EditItemIndex property of grid to -1 to switch out of Edit mode
   MyDataList.EditItemIndex = -1
   BindDataGrid() 'bind the data and display it

End Sub

 
Old November 16th, 2005, 03:42 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

What line produces the error?

 
Old November 17th, 2005, 11:28 AM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to webgen
Default

It is the objCommand.ExecuteNonQuery() line. thanks!!

 
Old November 17th, 2005, 12:35 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

   It is probably a mismatch in your Delete statement between AuthID and the DataKeys value. Check both of them and make sure the are the same, if not, convert one of them. Also, it would be good to use Try...Catch statements around your DB code. This will also help you view the error in a more detailed way.

Jim






Similar Threads
Thread Thread Starter Forum Replies Last Post
(0x800A000D) datatype mismatch peonysmiles ASP.NET 1.0 and 1.1 Basics 1 August 26th, 2008 08:13 AM
datatype umeshtheone SQL Server 2000 2 May 16th, 2007 11:56 AM
DataType Mismatch Errorror sirmilt BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 4 August 4th, 2006 09:05 AM
Datatype mismatch on datetime column??? reidcor SQL Server DTS 3 May 9th, 2005 02:13 PM
datatype ngang SQL Language 1 November 18th, 2003 09:55 AM





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