473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

data type mismatch in criteria expression

I am coding a website and have run into a problem I can't seem to figure out.

I keep getting the above error when I am trying to use this code.

Expand|Select|Wrap|Line Numbers
  1.     Protected Sub UpdateData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpdateData.Click
  2.  
  3.             Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
  4.             Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
  5.             Dim strInsert As String = "INSERT INTO Data(MajorProblem, Cat_Street_Number, Cat_Score, StartAddr, EndAddr, CatId, SubId, Sid, NeighborhoodID)VALUES("
  6.             Dim majorProblem As Integer = 0
  7.             dbCommand.Connection = dbConnection
  8.             dbCommand.Connection.Open()
  9.             If RubbishMajor.Checked Then
  10.                majorProblem = 1
  11.            Else
  12.                majorProblem = 0
  13.            End If
  14.            If OverFilledBins.Checked Then
  15.                Dim sub1 As String = 1
  16.                strInsert = strInsert & "'" & majorProblem & "', '" & OverFilledAddr.Text & "', '" & Rubbishscore.Text & "', '" & StartAddr.Text & "', '" & EndAddr.Text & "', "
  17.  
  18.                strInsert = strInsert & "'SELECT SubCat.CatId FROM SubCat WHERE  SubId = 1', 'sub1', "
  19.                strInsert = strInsert & "'SELECT Street_Lookup.Sid FROM Street_Lookup WHERE " & ddlStreetName.SelectedValue & " = St_name', "
  20.                strInsert = strInsert & "'SELECT Neighborhood.NeighborhoodID FROM Neighborhood WHERE " & ddlNeighborhood.SelectedValue & " = NeighborhoodDesc'"
  21.            End If
  22.  
  23.            strInsert = strInsert + ")"
  24.            dbCommand.CommandText = strInsert
  25.            dbCommand.ExecuteNonQuery()
  26.            dbCommand.Connection.Close()
  27.        End Sub
If someone could please tell me what Im doing wrong that would be amazing.
Dec 10 '07 #1
3 1557
Nicodemas
164 Expert 100+
Could you reformat that and post the line number the error occurs on?
Dec 11 '07 #2
25 dbCommand.ExecuteNonQuery()

that is the line the error occurs on, but I believe that itt occurs with where i concatenate my first select statement
Dec 11 '07 #3
jhardman
3,406 Expert 2GB
If you were to print out strInsert, what would it say?

Jared
Dec 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
3
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
2
by: igor.barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
5
by: blackburnj55 | last post by:
Hi, I am constructing a website for a bike shop. I am using dreamweaver and an access database to create it. I have made a query where two criteria are entered to get results. These are :...
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
1
by: Bobby Edward | last post by:
Using Access db with VS2008 (ASP.NET/VB.NET).... On the INSERT command I get this error: System.Data.OleDb.OleDbException: Data type mismatch in criteria expression. I haven't found a...
9
by: nixonmg | last post by:
When the Command Button "Notify" is clicked, I am wanting to send out an email to the user with appropriate information in the email (works great), check the "Notified" check box (does not work), and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.