Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

OleDbException: Data type mismatch in criteria expression.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bobby Edward - 05 Mar 2008 05:46 GMT
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 solution yet in my research.  Any idea what I might be
missing?

**************
Datasource setup as follows:
                           <asp:AccessDataSource ID="AccessDataSource1"
runat="server"
                               DataFile="~/BeachFuneral.mdb"
                               InsertCommand="INSERT INTO [ObitComments]
([ObitId], [CommentBy], [CommentEmail], [CommentRelation],
[CommentApproved], [CommentDateTime], [ObitComment]) VALUES (?, ?, ?, ?, ?,
?, ?)" >
                               <InsertParameters>
                                   <asp:Parameter Name="ObitId"  />
                                   <asp:Parameter Name="CommentBy" />
                                   <asp:Parameter Name="CommentEmail" />
                                   <asp:Parameter Name="CommentRelation" />
                                   <asp:Parameter Name="CommentApproved" />
                                   <asp:Parameter Name="CommentDateTime" />
                                   <asp:Parameter Name="ObitComment" />
                               </InsertParameters>
                           </asp:AccessDataSource>

**************
Code to insert as follows:
       With Me.AccessDataSource1
           .InsertParameters("ObitId").DefaultValue =
Request.QueryString("Id")
           .InsertParameters("CommentBy").DefaultValue =
Me.txtFullName.Text
           .InsertParameters("CommentEmail").DefaultValue =
Me.txtEmail.Text
           .InsertParameters("CommentRelation").DefaultValue =
Me.txtRelationship.Text
           .InsertParameters("CommentApproved").DefaultValue = True
           .InsertParameters("CommentDateTime").DefaultValue = Now.ToString
           .InsertParameters("ObitComment").DefaultValue =
Me.txtComment.Text
       End With
       Try
           Me.AccessDataSource1.Insert()
       Catch ex As Exception
           Response.Write(ex.ToString)
           Exit Sub
       Finally
           ' if ok then move on...
           Response.Redirect("Obit.aspx?Id=" & Request.QueryString("Id"))
       End Try
Kevin Spencer - 05 Mar 2008 13:17 GMT
You have not identified what data types your database is using, either in
this message, or in your code. However, you are attemtping to insert all
string values (text data type), with the exception of one field
(CommentApproved) which you are inserting a boolean value into. So, unless
all of the fields in the table are text except for that one, you would
certainly get that exception.

Signature

HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

> Using Access db with VS2008 (ASP.NET/VB.NET)....
>
[quoted text clipped - 53 lines]
>            Response.Redirect("Obit.aspx?Id=" & Request.QueryString("Id"))
>        End Try

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.