Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2007, 06:01 PM
Registered User
 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update problem

I don't know what I'm doing wrong.



When I make a change to the datagrid and click the button that has the following code it doesn't update for some reason.

        DataGrid1.Update()
        SqlDataAdapter1.Update(DataSet11)


Please help...

 
Old February 19th, 2007, 08:25 AM
Authorized User
 
Join Date: Nov 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ef1196
Default

Two possible causes:

1.) Is your sqlConnection open prior to issuing the update commands?
2.) Is there a primary key established for the table being updated?



Best Regards,
Earl Francis
 
Old February 20th, 2007, 06:29 AM
Registered User
 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

1.) Is your sqlConnection open prior to issuing the update commands?

I'm not sure what you mean by sqlConnection being open. It's connected, I verified that it's connected to the database before I compile the program.

2.) Is there a primary key established for the table being updated?

There are primary keys for each record in the row.



If what I'm saying has nothing to do with what you're asking, please forgive me.. :)

I'm very new to this.

I'm studying out of a book and I followed it to a 'T' on the whole connection wizard steps.

 
Old February 20th, 2007, 08:38 AM
Authorized User
 
Join Date: Nov 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ef1196
Default

You are most likely using a TableAdapter to connect to your data if you are new and studying from text. Check to make sure that the Update and Delete commands were properly generated. Review your text on configuring TableAdapters if necessary.



Best Regards,
Earl Francis
 
Old February 20th, 2007, 09:25 PM
Registered User
 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I redid the sqlconnection, sqldataadaptor and dataset connection. I made sure they were connected. The funny thing is I can update the records in the preview query of the wizard but I can't in the compiled program. I'm pulling my hair out. :)

 
Old February 21st, 2007, 08:39 PM
Authorized User
 
Join Date: May 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to notrosh
Default

Please post your code. I think that will help everyone is diagnosing this issue and solving it. ;)
 
Old February 21st, 2007, 10:25 PM
Registered User
 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm totally brand studying out of a book that seems to be a little misleading sometimes. Anyway, the program just has a datagridview control and 2 command buttons on it with a sqlconnection, sqldataadaptor and dataset connection, connecting to the northwind access database that I imported into sql server. Here's the code. I'm sure I'm missing somethings but please remember I'm new :)


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        SqlDataAdapter1.Fill(DataSet11, "Customers")



        With DataGridView1

            .DataSource = DataSet11

        End With




    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click


        DataGridView1.Update()
        SqlDataAdapter1.Update(DataSet11)

    End Sub
End Class







Similar Threads
Thread Thread Starter Forum Replies Last Post
Update problem filipczako ADO.NET 6 December 15th, 2005 11:58 AM
Update Problem skwilliams Classic ASP Databases 0 December 1st, 2005 11:02 AM
update problem lamdog ASP.NET 1.0 and 1.1 Basics 1 March 15th, 2005 11:59 PM
Update problem acko SQL Server 2000 3 June 29th, 2004 01:50 AM
update problem Justine Classic ASP Databases 21 May 26th, 2004 04:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.