473,804 Members | 3,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem updating a dataset within a button click handler

I am relatively new to Visual Basic 2005 Express Edition.
I am trying to create a simple program that:

1. Creates and populates a dataset in the form_load handler
2. Transfers control to a new form to input user changes to the data in a
Button2_Click event handler
3. returns control to the Button2_Click event handler to perform the dataset
update

However it can’t find the data adapter ‘custDA’ to perform the update in the
Button2_Click event handler.

Can anybody help please.

Many thanks.

Southcoaster.
Imports System.Data.Sql Client
Public Class MainCustomerSel ectionForm

Dim custDS As DataSet = New DataSet("Custom erSelection")
Dim CustomerRecordF orm As New CustomerRecordF orm

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Load

Dim builder As New System.Data.Sql Client.SqlConne ctionStringBuil der
builder("Data Source") = ".\SQLEXPRE SS"
builder("Attach DBFilename") = "C:\SQL Server 2000 Sample
Databases\NORTH WND.MDF"
builder("Integr ated Security") = True
builder("Connec t Timeout") = 30
builder("User Instance") = True

Dim nwindConn As New SqlConnection()
nwindConn.Conne ctionString = builder.Connect ionString

Dim custDA As SqlDataAdapter = New SqlDataAdapter( "SELECT * FROM Customers",
nwindConn)
nwindConn.Open( )

custDA.Fill(cus tDS, "Customers" )
Me.DataGridView 1.DataSource = custDS
Me.DataGridView 1.DataMember = "Customers"

End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click

CustomerRecordF orm.ShowDialog( )

*** ERROR OCCURS HERE AS THE COMPILER CANNOT FIND ‘CustDA’ ***

custDA.Update(c ustDS, "Customers" )

End Sub

End Class
Oct 29 '06 #1
0 941

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
272
by: Doug Holland | last post by:
Hi Ther I have an ASP.NET user control which contains a test panel defined as follows <asp:Panel ID="TestPanel" Runat="server" / In the OnInit method I designate an event handler to handle the user controls PreRender event and in the PreRender event handler I create a button as follows Button _Button = new Button() _Button.ID = "PRButton"
1
5296
by: sandman | last post by:
I've got a simple windows form with some bound textboxes and Save button. Each texbox is bound to column in a table in an Access database. The form fills fine - all the fields show the correct data for the record I load. So then I change the contents of one of the textboxes and click on the Save button. The button's event handler then calls the data adapter's Update method and I check the return value. Nada-zilch-nothing. I even put a...
4
2406
by: Wes | last post by:
Hello, I have an application using an xml dataset to store app and user settings. The problem I am having is related to writexml. I have a save button on my application that updates the dataset and then using the writexml(...) function saves the dataset to an xml file. I have noticed that the file does not change everytime I click the save button. I get no errors but the writexml function does not seem to be updating the xml file. ...
5
3044
by: Alastair Anderson | last post by:
I have created a very simple form with which I would like to update a single value in a single row of a database as a proof of concept. The relevant parts of the form are a DBWebTextBox (which is hooked into a column ORGANISATION.SHORT_NAME) and a Button which I am using as a submit button.
6
9859
by: mkobus | last post by:
Im relatively new, so please be patient with me... I need to update a parent .aspx screen from a popup and close the popup. Normally I would use 'window.opener.location.reload(true);self.close();' but i need the parent window not to reload or else data that the user has already entered will be lost during the IsPostBack. I need the 'Apply' button on the popup to trigger the 'Update' button on the parent screen. The script ive seen...
1
3555
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say black for example). I am dynamically creating the LinkButton controls and adding them into the table cell and I've also hooked up an event handler for each LinkButton's Click event. This all works fine. Now in the Link Button's Click event...
0
914
by: Dave Dodd | last post by:
Hi All, I am new to dotnet and so far I am really enjoy using it. I am trying to figure out if the dataset is supposed to be updated when IsPostBack is true. For instance, I have a page with some TextBox controls that are bound to a dataset columns. I make a modification to one of the TextBox's and click a button.
7
2649
by: Frank Maxey | last post by:
I am fairly new to VB.Net and am having a curious problem. I have an entry dialog form called from a main form. The calling form needs to check the DialogResult field for an OK response. In my button service in the dialog form, I have: Private Sub btnSave_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnSave.Click
4
2138
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a Delete button on the end of each row. I am unable to gain access to the event when the button is clicked. I don't fully understand how the click gets connected to the C# code,
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.