473,394 Members | 1,813 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,394 software developers and data experts.

Database cannot Update unable to find TableMapping

133 100+
Hello All,
I am getting an error trying to update datagridview1 , what i am trying to do is search for an item (BarCode.text) and then display the results to datagridview1 but i just cannot manage to do it , please help me i have been trying for days :(

here is what i have this code is extremely crappy as i have read lots of tutorials and searches....

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2.  
  3.  
  4. Public Class ServiceCompletedForm
  5.     Dim connStr As String
  6.     Dim conn As New OleDbConnection
  7.     Dim da As New OleDbDataAdapter
  8.     Dim ds As DataSet = New DataSet
  9.     Dim cnString As String
  10.     Dim sqlQRY As String
  11.     Dim myCmd As New OleDbCommand
  12.     Dim myDR As OleDbDataReader
  13.     Dim strSQL As String
  14.  
  15.  
  16.     Private Sub ServiceCompletedForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  17.  
  18.         DataGridView1.Columns.Add("BarCode", "Item Barcode")
  19.     End Sub
  20.  
  21.     Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
  22.         da.Update(ds, "ServiceCompleted")
  23.     End Sub
  24.  
  25.     Private Sub SearchBarcodeDELETE()
  26.         cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=..\data\Northwind.mdb"
  27.         sqlQRY = "SELECT * FROM ServiceCompleted " 'WHERE BarCode'"
  28.         conn = New OleDbConnection(cnString)
  29.         Try
  30.             conn.Open()
  31.             da = New OleDbDataAdapter(sqlQRY, conn)
  32.             'create command builder
  33.             Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(da)
  34.             'fill dataset
  35.             da.Fill(ds, "ServiceCompleted")
  36.             DataGridView1.DataSource = ds
  37.             DataGridView1.DataMember = "ServiceCompleted"
  38.         Catch ex As OleDbException
  39.             MsgBox(ex.ToString)
  40.         Finally
  41.             ' Close connection
  42.             conn.Close()
  43.         End Try
  44.     End Sub
  45.     Function IsConnected() As Boolean
  46.         Try
  47.             'Checks first if already connected to database,if connected, it will be disconnected.
  48.             If conn.State = ConnectionState.Open Then conn.Close()
  49.             conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=..\data\Northwind.mdb"
  50.             conn.Open()
  51.             IsConnected = True
  52.         Catch ex As Exception
  53.             MsgBox(ex.Message)
  54.         End Try
  55.     End Function
  56.     Public Function KeyAscii(ByVal UserKeyArgument As KeyPressEventArgs) As Short
  57.         KeyAscii = Asc(UserKeyArgument.KeyChar)
  58.  
  59.     End Function
  60.     Sub SearchBarcode(ByVal Barcode As String)
  61.         Try
  62.             If IsConnected() = True Then
  63.                 'Queries to database
  64.  
  65.                 strSQL = "SELECT * FROM servicecompleted WHERE BarCode = '" + Barcode + "' "
  66.  
  67.                 myCmd.CommandText = strSQL
  68.                 myCmd.Connection = conn
  69.                 da.SelectCommand = myCmd
  70.                 myDR = myCmd.ExecuteReader()
  71.  
  72.                 'Display results to table
  73.  
  74.                 While (myDR.Read())
  75.  
  76.                     DataGridView1.Rows.Add(myDR("BarCode")) ', myDR("Description"), myDR("Location"), myDR("Building_Number"), myDR("Test_Tag_Interval"))
  77.  
  78.                 End While
  79.             End If
  80.         Catch ex As Exception
  81.             MsgBox(ex.Message, , "SearchBarcode")
  82.         End Try
  83.         conn.Close()
  84.     End Sub
  85.  
  86.     Private Sub txtBarcode_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtBarcode.KeyPress
  87.         If Me.KeyAscii(e) = 13 Then
  88.             If IsConnected() = True Then Call SearchBarcode(txtBarcode.Text)
  89.             e.Handled = True
  90.         End If
  91.     End Sub
  92.  
  93.  
  94. End Class
Jan 11 '10 #1
0 1902

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

Similar topics

1
by: Paul Ballatti | last post by:
hi, I am attempting to update two databases simultaneously, from one ASP.NET Web Application, which is written in C#. One database is local i.e. on my localhost IIS and this has no problems at...
0
by: PaulB | last post by:
Hi there, Allthough I searched for previous posts, I was unable to solve my problem. I try to link my front-mdb with an Excel file using the next line DoCmd.TransferSpreadsheet acLink, 8,...
1
by: Azel | last post by:
Hi, I am trying to learn ADO.net and I keep running into problems trying to insert data into my Access Database: data.mdb. here is my code: <code> // Database Variables
1
by: cvncpu | last post by:
I have this function: public string SetUserInfo(string AuthID, DataSet dg2) { if (AuthID=="********") { Oconn.Open(); da.Update(dg2); Oconn.Close();
1
by: xaime | last post by:
Hi all, I have the code below. This is doing what I want, but always has the following exception: Update unable to find TableMapping or Datatable 'mytable' The code I'm using is: Try
1
by: Billy Yang | last post by:
Hello, I write a small program to build a web service. I fill a dataset with data from VFP database. After I put a record in the dataset and make the update. When updating the database I get an...
1
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and...
2
by: Ronald S. Cook | last post by:
In my client Windows application, I am receiving a DataSet containing one DataTable. This comes to my client via the business tier on a different physical machine (we're using WCF if that...
1
by: jonbartlam | last post by:
Hi There I'm not sure what exactly is going wrong here. I'm writing an application that retreives a table from a database (tbl_internalfaults) and updates it. (Actually, just the status column will...
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: 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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.