Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 April 4th, 2006, 02:39 PM
Authorized User
 
Join Date: Mar 2006
Location: Sofia, , Bulgaria.
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!
  #2 (permalink)  
Old April 4th, 2006, 07:40 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
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.
======================================
  #3 (permalink)  
Old April 5th, 2006, 04:39 AM
Authorized User
 
Join Date: Mar 2006
Location: Sofia, , Bulgaria.
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
  #4 (permalink)  
Old April 5th, 2006, 06:49 AM
Authorized User
 
Join Date: Mar 2006
Location: Sofia, , Bulgaria.
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?:)
  #5 (permalink)  
Old April 5th, 2006, 12:11 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
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.
======================================
  #6 (permalink)  
Old April 11th, 2006, 11:08 AM
Authorized User
 
Join Date: Mar 2006
Location: Sofia, , Bulgaria.
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
 


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
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



All times are GMT -4. The time now is 03:19 PM.


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