[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VB post update in dataset

Posted on 2012-03-22
4
Medium Priority
?
187 Views
Last Modified: 2012-04-07
I have a windows form that has a datagridview on it. I have added a button under the datagridview that when clicked is supposed to post the changes made in the dataset back to the database. The database is an MS Access mdb. The code I have is not working...

Private Sub btnSaveTime_Click(sender As System.Object, e As System.EventArgs) Handles btnSaveTime.Click
        Try
            Me.dgvTime.Update()
            Me.TblTimeBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me._Times__DataSet1)
            MessageBox.Show("Data saved!")
        Catch ex As Exception
            MessageBox.Show("Update failed!")
        End Try
    End Sub
0
Comment
Question by:rawilken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:rawilken
ID: 37752757
btw I am using .NET 4
0
 
LVL 8

Accepted Solution

by:
gpizzuto earned 1500 total points
ID: 37752810
First of all, you don't need to call Me.dgvTime.Update() because it does not update data, but REDRAWS the grid.

1) You can't use a query with more than ONE table (or you must call a Stored Procedure).
2) Your datatable MUST have a PRIMARY KEY
3) You cannot update READONLY fields

If you already checked these, please let us know more details about your tables and your query.

Hope this helps
0
 

Author Comment

by:rawilken
ID: 37752923
The dataset is comprised of one table, tblTime, that has a primary key. I have one record in the table and that one record is to be updated by the user through the vb Windows form. The record has three fields/columns, ID and TmStart and TmEnd. The primary key is ID and it is AutoNumber.
I have another datagrid view that is similar except the input is a date in the yyy-mm-dd format and the table the dataset uses is tblDates.
I use this input from the user, combining the Start entries into one field and use that to filter data in other datagridviews through queries in the database. So far I have not been able to get the filter to work. It seems that the changes made in the time and dates datagridviews are not being saved properly.
0
 
LVL 8

Expert Comment

by:gpizzuto
ID: 37753054
Have you set up properly the column format of the Date field ?
You need to use MM (month) and not mm (minutes) format: yyyy-MM-dd
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question