Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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 April 4th, 2006, 02:39 PM
Authorized User
 
Join Date: Mar 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kalchev
Default Data type mismatch in criteria expression.

Hello,
what I am trying to do is a dinamyc treeview that take the source form a AccessDatabase. But I recieve that err:
Quote:
quote:
Data type mismatch in criteria expression.
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.OleDb.OleDbException: Data type mismatch in criteria expression.

Source Error:


Line 91: Dim titlesForAuthors As New DataSet()
Line 92:
Line 93: adapter.Fill(titlesForAuthors)
Line 94:
Line 95: If titlesForAuthors.Tables.Count > 0 Then


Source File: C:\Documents and Settings\gosho\My Documents\Visual Studio 2005\WebSites\WebSite3\Default2.aspx Line: 93
And here is the part of the Source:

Code:
Private Sub FillTitlesForAuthors(ByVal node As TreeNode)

        Dim CategorID As Integer = node.Value
        Dim connString As String = ConfigurationManager.ConnectionStrings("autodib").ConnectionString
 
        Dim connection As New OleDb.OleDbConnection(connString)
 
        Dim command As New OleDb.OleDbCommand("Select Produkti.ProdID,Produkti.ImeProd From Produkti" + " Inner Join Kategoria on Kategoria.CategorID = Produkti.CategorID " + " Where Kategoria.CategorID = '" + CategorID + "'", connection)
 
        Dim adapter As New OleDb.OleDbDataAdapter(command)
 
        Dim titlesForAuthors As New DataSet()
 
        adapter.Fill(titlesForAuthors)
 
        If titlesForAuthors.Tables.Count > 0 Then
 
            Dim row As DataRow
            For Each row In titlesForAuthors.Tables(0).Rows
                Dim NewNode As TreeNode
                NewNode = New TreeNode(row("ImeProd").ToString(), row("ProdID").ToString())
 
                NewNode.PopulateOnDemand = False
 
                NewNode.SelectAction = TreeNodeSelectAction.None
 
                node.ChildNodes.Add(NewNode)
 
            Next
 
        End If
 
    End


I've tried:
Code:
Dim command As New OleDb.OleDbCommand("Select Produkti.ProdID,Produkti.ImeProd From Produkti" + " Inner Join Kategoria on Kategoria.CategorID = Produkti.CategorID " + " Where Kategoria.CategorID = " + CategorID, connection)
And it didn't work Gave mi kind of query problem.I am sure it is in the select.. but I do not know what exactly. Hope somebody has a better ideas :o

Thanks!
 
Old April 4th, 2006, 07:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Have you tried the query directly to the database, see if it returns rows.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old April 5th, 2006, 04:39 AM
Authorized User
 
Join Date: Mar 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kalchev
Default

When I tried i've found the mistake:) I've jumped one table over in the relationship and now it is ok. Thank you
 
Old April 5th, 2006, 06:49 AM
Authorized User
 
Join Date: Mar 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kalchev
Default

but now it happens something strange:
for example a node in Depth=1 has 2 child nodes it double the Parent node too, o if they are tree so it makes 3 parent nodes with tha same name.. Any Idea why is that?:)
 
Old April 5th, 2006, 12:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I can not tell from the code provided.
Are you saying that the parameter 'node' is created three times?
If so please show the code that calls FillTitlesForAuthors(ByVal node As TreeNode)





======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old April 11th, 2006, 11:08 AM
Authorized User
 
Join Date: Mar 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kalchev
Default

yes exactly but I do not know exactly why but when I separated the SELECT Command using "" & it jut worked perfect. Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
data type mismatch in criteria expression coreyjustin Classic ASP Basics 1 December 10th, 2007 06:49 PM
Data type mismatch in criteria expression Tawanda BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 0 May 5th, 2007 05:29 PM
data type mismatch in criteria expression xigler Access 3 March 23rd, 2007 08:54 AM
Data type mismatch in criteria expression. imercha Classic ASP Basics 3 November 23rd, 2006 11:09 AM
Data type mismatch in criteria expression. EDEN Access ASP 1 November 22nd, 2006 01:19 AM





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