Update unable to find TableMapping .. or Datatable

Discussion in 'ASP .Net' started by xaime, May 5, 2005.

  1. xaime

    xaime Guest

    Hi all,

    I have the code below. This is doing what I want, but always has the
    following exception:

    Update unable to find TableMapping ['mytable'] or Datatable 'mytable'

    The code I'm using is:
    Try

    Dim aDispuesto As Single, aDisponible As Single

    aDispuesto = Session("dispuesto") + APagar

    aDisponible = Session("disponible") - APagar

    ' conexión con tbEmprendedor

    Dim oDSemp As Data.DataSet = New DataSet("DatasetEmprendedor")

    ' consulta de actualización con nuevos valores

    Dim SQLemp As String

    SQLemp = "UPDATE tbEmprendedor" & _

    " SET Dispuesto = " & aDispuesto & ", Disponible = " & aDisponible & _

    " WHERE id_Emprendedor = " _

    & CType(idEmp, Integer) & ";"

    Dim oDAemp As New OleDb.OleDbDataAdapter(SQLemp, oCnn1)

    oDAemp.Fill(oDSemp)

    oDAemp.UpdateCommand = New OleDb.OleDbCommand

    oDAemp.UpdateCommand.CommandText = SQLemp

    oDAemp.UpdateCommand.Connection = oCnn1

    ' Actualizar

    oDAemp.Update(oDSemp, "tbEmprendedor")

    oCnn1.Close()

    Catch ex As Exception

    lblMensaje.Text = lblMensaje.Text & "<br>Excepcion tbEmprendedor: {0}" &
    ex.Message

    End Try



    Thanks for helping me.
    xaime, May 5, 2005
    #1
    1. Advertising

  2. xaime

    David Lloyd Guest

    Xaime:

    One thing I notice, and this depends on parts of the code that are not
    shown, is that when you fill your dataset, you are not using one of the
    overloads of the Fill method to give the table a name. I believe the
    default name is just "Table." Therefore when you use the Update method,
    your reference to "tbEmprendedor" would not be recognized.

    This assumes of course that there is only one table in your dataset, which
    again depends on the full code you are using.

    --
    David Lloyd
    MCSD .NET
    http://LemingtonConsulting.com

    This response is supplied "as is" without any representations or warranties.


    "xaime" <> wrote in message
    news:...
    > Hi all,
    >
    > I have the code below. This is doing what I want, but always has the
    > following exception:
    >
    > Update unable to find TableMapping ['mytable'] or Datatable 'mytable'
    >
    > The code I'm using is:
    > Try
    >
    > Dim aDispuesto As Single, aDisponible As Single
    >
    > aDispuesto = Session("dispuesto") + APagar
    >
    > aDisponible = Session("disponible") - APagar
    >
    > ' conexión con tbEmprendedor
    >
    > Dim oDSemp As Data.DataSet = New DataSet("DatasetEmprendedor")
    >
    > ' consulta de actualización con nuevos valores
    >
    > Dim SQLemp As String
    >
    > SQLemp = "UPDATE tbEmprendedor" & _
    >
    > " SET Dispuesto = " & aDispuesto & ", Disponible = " & aDisponible & _
    >
    > " WHERE id_Emprendedor = " _
    >
    > & CType(idEmp, Integer) & ";"
    >
    > Dim oDAemp As New OleDb.OleDbDataAdapter(SQLemp, oCnn1)
    >
    > oDAemp.Fill(oDSemp)
    >
    > oDAemp.UpdateCommand = New OleDb.OleDbCommand
    >
    > oDAemp.UpdateCommand.CommandText = SQLemp
    >
    > oDAemp.UpdateCommand.Connection = oCnn1
    >
    > ' Actualizar
    >
    > oDAemp.Update(oDSemp, "tbEmprendedor")
    >
    > oCnn1.Close()
    >
    > Catch ex As Exception
    >
    > lblMensaje.Text = lblMensaje.Text & "<br>Excepcion tbEmprendedor: {0}" &
    > ex.Message
    >
    > End Try
    >
    >
    >
    > Thanks for helping me.
    >
    >
    David Lloyd, May 5, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. Babe
    Replies:
    1
    Views:
    8,317
    Kevin Spencer
    Aug 15, 2003
  2. Fredrik Rodin

    Sort a datatable and create a new datatable

    Fredrik Rodin, Feb 16, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    9,031
    paul.mariotti
    Sep 28, 2007
  3. TSA
    Replies:
    1
    Views:
    715
  4. =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=

    DataTable Find/Update

    =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=, Mar 18, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    16,636
    =?Utf-8?B?U29sZWwgU29mdHdhcmU=?=
    Mar 22, 2005
  5. =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=

    Use of TableMapping ?

    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=, Nov 15, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,966
    Karl Seguin
    Nov 15, 2005
Loading...

Share This Page