Hi
I have a DataGridView,I want the user to Add,Edit and delete rows from the table
My code is:
I have 2 questions:Code:Private cn As New SqlConnection("Data Source=localhost;Initial Catalog=NorthWind;Integrated Security=True") Private da As New SqlDataAdapter() Private dt As New DataSet() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cm As New SqlCommand("SELECT CustomerID,CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax FROM Customers", cn) da.SelectCommand = cm Dim cmbuilder As New SqlCommandBuilder(da) 'auto generate the UpdateCommand,InsertCommand and DeleteCommand da.Fill(dt, "Customer") Me.DataGridView1.DataSource = dt Me.DataGridView1.DataMember = "Customer" End Sub Private Sub BtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click Me.DataGridView1.BindingContext(dt).EndCurrentEdit() Me.da.Update(dt) End Sub
When I edit a row and then press Save the following message appears:
Update unable to find TableMapping['Table'] or DataTable 'Table'.
Also I don't want to display CustomerID in my DataGridView.
how can I make it invisible(I want to include CustomerID in my select statement but not display it in the datagridview)
Any help?




Reply With Quote