System.Data.OleDb.OleDbException was unhandled by user code - Data type mismatch in criteria expresion

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

I need a pair of fresh eyes to look at this and ponit me in the right direction!

Can anybody help me?

this is the offending code and the exeption arrives at line 6 (DetailsSource.Delete())

Sub

Get_Command(ByVal Src As Object, ByVal Args As DetailsViewCommandEventArgs)
If Args.CommandName = "Yes" Then
DetailsSource.DeleteCommand = "DELETE FROM tblLocalNews " & _
"WHERE ID = '" & _
ViewState(
"ID") & "'"
DetailsSource.Delete()
GridView.DataBind()
EditMSG.Text =
"• Record " & ViewState("ID") & " deleted"
End If

 

0
I
3/10/2007 4:28:16 PM
asp.net.access-datasource 4679 articles. 0 followers. Follow

2 Replies
1614 Views

Similar Articles

[PageSpeed] 25

Id your ViewID a numeric datatype?  Only your SQL has it delimited as a text datatype.  If it's a number, change it to:

DetailsSource.DeleteCommand = "DELETE FROM tblLocalNews " & _
"WHERE ID = " & ViewState("ID")

 


Regards Mike
[MVP - ASP/ASP.NET]
My site
0
Mikesdotnetting
3/10/2007 5:01:55 PM

thats great thanks a lot.

0
I
3/10/2007 6:41:01 PM
Reply:

Similar Artilces:

OleDbException was unhandled by user code
Hi, I am a very beginner in .net , and i am trying to make a project in asp.net via vb script. i made my database in microsoft sql server 2005. i had design my webforms and i also made the tableadapters. in the tableadapter i make the procedure insert. from the tableadapter i can save a row to database but at run time of my webpage i canĀ“t. when i am choosing the button save , it appears an error. in the trace it writes: at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)   at System.Data.OleDb.OleDbCommand.Ex...

OleDbException was unhandled by user code
Hello, I made and ASP.Net application with C# 2005 with Access database. In my development machine I could run my application and do some actions that connect to database. I use myConnection.Open() method to connecting to database. I also call myConnection.Close() method after each call to opening. But sometimes the application crashes and visual studio hang on  myConnection.Open()and show this error message : " OleDbException was unhandled by user code". I restart application but that problem remains and program hang on myConnection.Open() again. After restarting IIS this p...

System.NullReferenceException was unhandled by user code
I am using a method to retrieve a string from data base ..split it and populate it on screen using Grid View. Here is my codePrivate Sub PopulateReportFields() Dim reportfields As String = NothingDim reportfieldsarray As Array Dim ldgiSelect As GridViewRow = Nothing Dim lcbCurrentCheckbox As CheckBox = Nothing Dim ldtDatasource As Data.DataTable = Nothing Dim arrayelement As String = Nothing Try dgReportFields.DataSource = Nothingreportfields = Session("ReportFields") reportfields = reportfields.Replace("Count(", "")reportfields = reportfields.Replace...

System.IndexOutOfRangeException was unhandled by user code
Hi i keep getting this error with my code and i have never had this error before any one know whythe error occours when the while loop is running and trying to get data from the database but i know the syntax for the querry works fine becuase it draws back information from the database when i use mysql querry browser thanks dan   using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; usin...

System.NullReferenceException was unhandled by user code
I am new to C#. I was doing pretty well, until I ran into the "System.NullReferenceException was unhandled by user code  Message="Object reference not set to an instance of an object" error. Here is the code:     String[] strRoutes;    int k = 0;    String GetRoute(String route)    {            strRoutes[k] = route;            k++;            return...

System.NullReferenceException was unhandled by user code
I am building an edit/update admin page and have a problem when I run my code and try and catch the exeption this error is shown ; Object variable or With block variable not set. Can anybody help me with a work around for this error, as i'm a little stuck? Here's the code below. <%@ Page Language="VB" AutoEventWireup="false" MaintainScrollPositionOnPostback="true" MasterPageFile="~/Content.master" CodeFile="adminLatestNews.aspx.vb" Inherits="aspx_pages_admin_adminLatestNews" %> <asp:Content ID="Content2" runat="server" ContentPlaceHolderID="ContentPlaceHolderMain">&...

System.Security.SecurityException was unhandled by user code
System.Security.SecurityException was unhandled by user code this is the error that I am recieving when I execute my system any thought on how to fix this prblmThank You in advance You need to provide more information in order to get help. Show the code that breaks. Typically it is a rights issue, e.g. on folders or files.Cheers,Rodneyhttp://www.RodneyHeinkens.com - Sharing .NET and SQL Experiences Public Sub WriteToEventLog(ByVal sqlCmd As String, ByVal RowCount As Integer, ByVal errmsg As String) If Not EventLog.SourceExists("Pathways") ThenEventLog.CreateEventSource(&q...

System.NullReferenceException was unhandled by user code #2
Dear All,   I have got this error on the part of my gridview that does the binding and here is the error highlighted:  if (RdOption.SelectedValue.IndexOf("DlrName") >= 0) {SqlCommand _oCmd = new SqlCommand("DealerSearch_Name", conn);_oCmd.CommandType = CommandType.StoredProcedure; conn.Open(); _oCmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar));_oCmd.Parameters["@Name"].Value = txtDealerCode.Text;  SqlDataReader _oDreader = _oCmd.ExecuteReader();   gvDealers.DataSource = _oDreader;    gvDea...

System.Web.HttpException was unhandled by user code
I have a button on a WebForm.<asp:Button ID="SearchButton" CssClass="Button" runat="server" Text="Search" Width="96px" Height="24px" PostBackUrl="~/SearchAds.aspx" /> Here is a portion of the SearchAds.aspx.cs: public partial class SearchAds_aspx : System.Web.UI.Page { private bool _showCategoryBrowseForTopLevel = true;private bool _advancedSearchInEffect;protected void Page_Load(object sender, EventArgs e) { _advancedSearchInEffect = Convert.ToBoolean(ViewState["advancedSearchInEffect"]);if (!Pag...

System.Resources.MissingManifestResourceException was unhandled by user code
I converted a web project from VS 2003 / .NET 1.1 to VS 2008 / .NET 3.5.  I'm getting an error when this line of code executes: Private m_oResFile As ResourceManager Public ReadOnly Property ResourceString(ByVal ID As String) As String GetReturn m_oResFile.GetString(ID) End Get End Property  The error text is as follows: System.Resources.MissingManifestResourceException was unhandled by user code  Message="Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "MyApp.AppName.WebUI.Financial.resources&quo...

VB.net code to create user errors in accessing webservice
Hello,  I'm trying the code below, but receiving the errors 1 and 2. Can someone help me with this?  WebServiceServer is added as webreference http://WebServiceServer/MPSWS/ManagedActiveDirectory/service.asmxPublic Class Form1    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click         Dim ldapPath As String        Dim userPrincipalName As String        Dim samAccountName As String   ...

Value of type 'System.Net.Mail.MailMessage' cannot be converted to 'System.Net.Mail.AlternateView'
Trying to create an alternateview to send a txt email with the html formatted email.  I've used string builder to create the whole email, but I get this error.  Any ideas why?  i've bolded the line that throws the error... Dim EmailBodyTxt As New StringBuilder EmailBodyTxt.Append("<html><style type='text/css'>.table{border:solid; border-color:#006666; width:600;} ")EmailBodyTxt.Append("<body><table class='table'><tr><td colspan='2'><h1>Test<br />RESPONSE SYSTEM</h1></td>...

Accessing user control in repeater from code behind in VB.net would be great
Hello i have a repeater which has a user control hard coded inside of it. I would like to be able to access the properties of the user control from code behind, but am having no luck "seeing" the usercontrol. If someone could help me out, that would be great.  Here is the repeater....<asp:Repeater ID="Repeater0" runat="server"> <HeaderTemplate> </HeaderTemplate> <ItemTemplate> <uc1:billToInfo ID="billToInfo1" billTo="<%#Container.dataItem %>" runat="server" /> </It...

Access VB Code to Read User Profile Directory on Windows System
This question is not .NET related, but I was hoping someone might be able to help with a simple access function that can return the name of a user's profile.  For example, C:\Documents and Settings\jsmith  return jsmith Thanks for any assistance. Try using: Environment.UserName This will return the current UserName for the logged on user.- WilliamPlease mark the most helpful reply/replies as "Answer".Give some of my PWSK modules a try. Thanks.  Here is another method for anyone who needs the user name.   Declare Function WNetGetUser Lib &quo...

System.Net.Mail is giving error CS0029: Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress'
I'm getting an error while trying to use the wizard to create a form and than pass it the vaibles to Mail. Any help would be much appreciated. SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); try {   message.From = txtEmail.Text; message.To.Add("admin1@yoursite.com"); message.Subject = "Feedback"; message.CC.Add("admin1@yoursite.com"); message.CC.Add("admin2@yoursite.com"); message.IsBodyHtml = false; message.Body = txtMessage.Text; smtpClient.Send(message); lblStatus.Text = "Email successfully sent."; } catch (Exception ex) { lbl...

Web resources about - System.Data.OleDb.OleDbException was unhandled by user code - Data type mismatch in criteria expresion - asp.net.access-datasource

Resources last updated: 1/20/2016 11:14:20 PM