Solved

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

Posted on 2007-11-23
3
248 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
ID: 20341518
just add an index to the table, make it a unique key.
0
 

Author Comment

by:BIGZIPZ1
ID: 20341651
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
ID: 20341765
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

912 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

21 Experts available now in Live!

Get 1:1 Help Now