System.Data.OleDb.OleDbException: Data type mismatch in criteria expression. #2

I am having trouble using OleDb within an ASP.NET application (C#) to write to a Yes/No data field in Access. I have a checkbox on my ASP.NET page and want this to save to a Yes/No field in an Access database. No matter what I try I get a "data type mismatch" message. I've tried the following variations to no avail:

1.

cmd.Parameters.Add("@SubsidyDoc", this.cbLeaseSubsidy.Checked);

2.

if (this.cbLeaseSubsidy.Checked == true)

     cmd.Parameters.Add("@SubsidyDoc","-1");

else

     cmd.Parameters.Add("@SubsidyDoc","0");

3.

if (this.cbLeaseSubsidy.Checked == true)

     cmd.Parameters.Add("@SubsidyDoc","True");

else

     cmd.Parameters.Add("@SubsidyDoc","False");

4.

if (this.cbLeaseSubsidy.Checked == true)

     cmd.Parameters.Add("@SubsidyDoc","Yes");

else

     cmd.Parameters.Add("@SubsidyDoc","No");

 Any help would be greatly appreciated. Thanks. 

0
flyfreedom
9/19/2006 6:18:34 PM
asp.net.access-datasource 4679 articles. 0 followers. Follow

1 Replies
1009 Views

Similar Articles

[PageSpeed] 32

Use OleDbType.Boolean as the type for the Yes/No parameter:

OleDbCommand cmd = new OleDbCommand("SELECT * FROM Table1 WHERE flag=@f", conn);
cmd.Parameters.Add("f", OleDbType.Boolean);
cmd.Parameters["f"].Value = Boolean.FalseString;


Welcome to my SQL/ASPNET forum for Chinese
http://51up.org/bbs/forumdisplay.php?fid=38
0
Iori_Jay
9/20/2006 9:59:36 AM
Reply:

Similar Artilces:

System.Data.OleDb.OleDbException: Data type mismatch in criteria expression.
Hi Forum, I have a login script working using text as password, i want to change this to a number, format (000) 000-000, when i submit 025987654 which is formated (025) 987-654 in a field im receiving; Data type mismatch in criteria expression. Any help out there!!! Thanks Paul if the password is truly a number, then you need to drop the quotes from around it when you build the sql statement i.e. select * from tblUser WHERE Password=025987654 and NOT select * from tblUser WHERE Password='025987654' Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? T...

System.Data.OleDb.OleDbException: Data type mismatch in criteria expression. HELP ME :)
Hellothis is my select code1 Dim ConnString1 As String = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|Nwind2003(Good).mdb" 2 Dim sqlstring3 As String = "SELECT * FROM customers WHERE CustomerID= '" & CustomerID & "'" 3 Dim conn2 As New OleDbConnection(ConnString1)4 Dim cmd2 As New OleDbCommand(sqlstring3, conn2)5 cmd2.CommandType = CommandType.Text6 Response.Write(sqlstring3)7 8 conn2.Open()9 Dim reader As OleDbDataReader = cmd2.ExecuteRe...

System.Data.OleDb.OleDbException was unhandled by user code
Master/Detail Editing - DetailsView I have created a master/detail setup where a GridView displays an complete index to all records in the my database. This in turn links to a DetailsView which gives editing access (New, Update and Delete) to the aforementioned individual records. The first to parts of my application work fine I can add to the access database and update to the access database. However when I attempt to delete from the database i am met with the error 'System.Data.OleDb.OleDbException was unhandled by user code - Data type mismatch in criteria ...

error:An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
************* Edited by moderator Adec *************** Inserted missing < code></ code> tags. Always include such tags when including code in your postings. Don't force the moderators to do this for you. Many readers disregard postings without the code tags. ************************************************** the error "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll " occured in the line CONm.open() the code is below: CONM.ConnectionString = "Provider=""MSDAORA.1"";User ...

The .Net Data SQL Provider (System.Data.SqlClient) requires Microsoft Data Access Components(MDAC) version 2.6 or later.
I am getting error like The .Net Data SQL Provider (System.Data.SqlClient) requires Microsoft Data Access Components(MDAC) version 2.6 or later. i am working with windowsXP. Already in my system i have MDAC 2.7. I donot know why am i getting error like this. anybody help me please...

Data type mismatch in criteria expression. #2
I SEE THIS ERROR WHEN I WANT INSERT A RECORD TO MY DATABASE (MDB). I ADDED ASPNET USER IN MY FILE SECURITY. I CAN UPDATE AND DELETE WHITHOUT ANY ERROR. PLEASE HELP ME. THANK YOU.   SOURCE: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="oladmin.aspx.vb" Inherits="oladmin" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="...

Data type mismatch in criteria expression. #2
Hello everyone, This is a part of code of a page which is been redirected from a hyperlinkcolumn of another page ... musteri_kod is a Integer-defined column in my database ... I tried .ToString or As Integer, it always says "Data type mismatch in criteria expression." ... Any help? Sub Page_Load(Src As Object, E As EventArgs) Dim musteri_kod As String musteri_kod=(Request.QueryString("id")).ToString kod.Text=musteri_kod kod.Visible="True" Dim MyConn as New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; DAT...

Data type mismatch in criteria expression #2
Hi all, i am nw getting this data type mismatch error in testproduct.aspx. this is my code below<code> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here If Not Page.IsPostBack Then Dim id As String = Session("clicked") Dim cnn As New OleDbConnection _ ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & Server.MapPath("speedy.mdb")) Dim strSQL As String = "SELECT * FROM Products WHERE product_id = '" + id + "' " Dim cmd As New OleDbCommand(strSQL, cnn) Dim dr As OleDbDataRea...

Data type mismatch in criteria expression #2
Hi,I am getting this error message " Data type mismatch in criteria expression."  when I am trying to pass a number like 2.3 or 4.5 or 56.78 as a parameter as follows cmdInsert.Parameters.Add("@Funds", OleDbType.Double).Value = dFunds The data type in access is number with field size Decimal and with  2 decimal places. How can I fix this issue?Thanks Please show the actual command you are using (the SQL String or the SP).Starting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog Thanks, here is the actual command Dim strSunOpen, strSunClose, strNotes As...

Data type mismatch in criteria expression #2
If objCommand.ExecuteScalar() = 0 Then strSQLQuery = "INSERT INTO Shopincart " & "(ShopincartID,OrderDate,Username,Paid)" & " VALUES (" & "'" & Session("ShopincartID") & "', " & "'" & Today & "', " & "'" & Session("Login") & "', " & "'" & "No" & "'" & ")"objCommand = New Data.OleDb.OleDbCommand(strSQLQuery, objConnection) objCommand.ExecuteNonQuery(...

Oledbexception data type mismatch in criteria expression
I am trying to retrieve a number from a query in an access database and am getting the followign error: oledbexception was unhandled by user code data type mismatch in criteria expression  The code is as follows:   Protected Sub GridView2_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView2.SelectedIndexChanged Dim maxDay As String maxDay = "SELECT [MaxofDayNumber] FROM [qryMaxDay] WHERE [entryID]='" & GridView2.SelectedRow.Cells(5).Text & "'" 'maxDay = "SELECT [...

Error Message:Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Hi,           I am trying to read MS Excel file using asp.net and getting error. I have already used this code in another server (Windows 2003 server) before 6 month successfully. But I have same OS in current server only .net version is different.Current Server Configuration : OS : Window Server 2003.net Framework : 3.5 MS Office 2003 My Code is here :  OleDbConnection OledbCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\inetpub\\wwwroot\\BEHR_ETMS\\TempDir\\Group.xls;Extended Properties=Excel 8.0;HDR=NO;&qu...

System.Data.OleDb.OleDbException: The DataType do not match in the criteria expression.
Hi I have a little code that get the data from a db the select code line works in VS2005 i can make a debug and it return the number 1, so thats ok, but after the select lineDBAdapter3.Fill(DBDataSet3, "KennelEnggaardText") I get this error:System.Data.OleDb.OleDbException: The DataType do not match in the criteria expression. I want to take the record ID 1's text and place it in a FormView code. Can someone plz. help me.My code is: 1 Private Sub OpenDB3() 2 ' Connection yil en database samt SQL Select forspørgsel 3 DBConnection3 = New OleDbConnection(C...

The .Net Framework OleDb Data Provider requires Microsoft Data Access Components(MDAC) version 2.6 or later.
Have installed .NET Frame work on Windows Server 2000. When I run my windows service application, getting below error in Application events.   The .Net Framework OleDb Data Provider requires Microsoft Data Access Components(MDAC) version 2.6 or later.  Version 2.53.6200.1 was found currently installed.   at System.Data.Common.ADP.CheckVersionMDAC(Boolean ifodbcelseoledb)   at System.Data.OleDb.OleDbConnectionInternal.GetObjectPool()   at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection conne...

Web resources about - System.Data.OleDb.OleDbException: Data type mismatch in criteria expression. #2 - asp.net.access-datasource

Resources last updated: 12/21/2015 12:22:19 PM