Solved

How do I create an SQL query to save changes in my database?

Posted on 2007-11-23
3
247 Views
Last Modified: 2010-04-23
I have a database table called table1 which I have loaded into a visual basic program. When I dragged the icon from the data sources window to the form and created the datagrid, a toolbar was created with a save button on. However, when I click it to save changes, the changes are not actually saved.

I navigated to the properties of my tableadapter and found that the updatecommand box was empty (so I assume the update command does nothing when called in a program).

What would I need to put in a new query to save changes to my database? It only has 2 columns: Episode and Rating.

Thanks
0
Comment
Question by:BIGZIPZ1
3 Comments
 
LVL 16

Expert Comment

by:SQL_SERVER_DBA
Comment Utility
just add an index to the table, make it a unique key.
0
 

Author Comment

by:BIGZIPZ1
Comment Utility
But the updatecommand field is empty in the properties. I must have deleted it when I was trying to get it to work. If the field is empty then when I do tableadapter.update it will execute an empty command right?
0
 
LVL 3

Accepted Solution

by:
ScottParker earned 500 total points
Comment Utility
You will probably have to start over.

First add a Unique key to your table like suggested by the previous person,
then go back though the steps and you will end up with something like the following in your forms code..

    Private Sub PendingeventsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PendingeventsBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.PendingeventsBindingSource.EndEdit()
        Me.PendingeventsTableAdapter.Update(Me.Sh_galaxy1DataSet.pendingevents)

    End Sub
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now