473,657 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid Update Problem

I haven't used the VS Studio's drag&drop method to create my connection,
adapters and datasets, but I typed them all. The situation is like this:

There is a listbox with members pulled from the database.(I am using an
access db). The user selects one value from the listbox and clicks on one of
two buttons "ThisWeek" or "LastWeek". The button click events each has its
own SQL statement, pulling datarows from two different tables in the
database(they are related with "employeeID ", which is selected in the
listbox I told before). Then the data adapter fills the dataset and it's
connected to one datagrid. The datagrid shows the values if the click event
completes successfully. But as I say, all the database connection, filling
and close processes are done in the click event.

The problem starts right after that. The user has the choice to modify the
dataset using the datagrid. And to update, he has to click on the "Update"
button in the form. But I don't kow how to make the update in antoher click
event. Since the datasets are created and tied to the grid in a different
click event. Now in another click event, the dataset is not recognized. So I
have to fill a new dataset, but this time, how is it going to recognize the
changes made to the dataset.

I am not very familiar with datagrids and datasets, so the topic is a little
bit out of my scope. After I looked through the Internet and forums, in all
the similar problems, they have a common thing that, they were filling the
dataset in the form_load events with simple sql statements. In my case, the
sql statement is dynamically changing with the value selected in a listbox
and the button pressed(Remembe r two buttons, "thisweek" and "lastweek") . And
the dataset is filled in a click event of one button. And update should be
in another click event of another button.

I hope I could explained my problem clearly. Any help would be highly
appreciated. Thanks for your time and comments in advance,
Reney
Nov 20 '05 #1
3 3284
If I undertstand youre problem correctly . . .

You need to declare your dataset, dataadapter and connections as class (
Form ) members, this way you can alter them from any click event. These can
be called during initialisation and your datasets populated diring
form_load.

If I have misunderstood you, please clarify

Regards

I haven't used the VS Studio's drag&drop method to create my connection,
adapters and datasets, but I typed them all. The situation is like this:

There is a listbox with members pulled from the database.(I am using an
access db). The user selects one value from the listbox and clicks on one of two buttons "ThisWeek" or "LastWeek". The button click events each has its
own SQL statement, pulling datarows from two different tables in the
database(they are related with "employeeID ", which is selected in the
listbox I told before). Then the data adapter fills the dataset and it's
connected to one datagrid. The datagrid shows the values if the click event completes successfully. But as I say, all the database connection, filling
and close processes are done in the click event.

The problem starts right after that. The user has the choice to modify the
dataset using the datagrid. And to update, he has to click on the "Update"
button in the form. But I don't kow how to make the update in antoher click event. Since the datasets are created and tied to the grid in a different
click event. Now in another click event, the dataset is not recognized. So I have to fill a new dataset, but this time, how is it going to recognize the changes made to the dataset.

I am not very familiar with datagrids and datasets, so the topic is a little bit out of my scope. After I looked through the Internet and forums, in all the similar problems, they have a common thing that, they were filling the
dataset in the form_load events with simple sql statements. In my case, the sql statement is dynamically changing with the value selected in a listbox
and the button pressed(Remembe r two buttons, "thisweek" and "lastweek") . And the dataset is filled in a click event of one button. And update should be
in another click event of another button.

I hope I could explained my problem clearly. Any help would be highly
appreciated. Thanks for your time and comments in advance,
Reney

Nov 20 '05 #2
Thanks for the quick response One Handed Man. I have corrected my
problem by
referencing your message.

I have a new question now though. The sql statement that I was using in
my
adapter was a join query, involving two tables, which have parent/child
relation. Now I learnt that, if the dataadapter's select command
references
more than one table, the commandbuilder won't work. So what is the best
solution for this situation? Could you recommend me any sites that have
sample solutions for such situations.

Thanks in advance for your responses.
Reney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Thanks for the quick response One Handed Man. I have corrected my problem by
referencing your message.

I have a new question now though. The sql statement that I was using in my
adapter was a join query, involving two tables, which have parent/child
relation. Now I learnt that, if the dataadapter's select command references
more than one table, the commandbuilder won't work. So what is the best
solution for this situation? Could you recommend me any sites that have
sample solutions for such situations.

Thanks in advance for your responses.
Reney
Nov 20 '05 #4

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

Similar topics

2
9920
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell (multi-select without modifier keys). I got that working fine, but I also wanted to keep rows selected after a sort, which I do by storing the row's id in an arraylist. The idea was to do the sort and then go back and re-select the rows with that...
9
1642
by: Pam Ammond | last post by:
After clicking btnDeleteSize_Click in frmSize, I move to frmSizeDelete, allow deleting a Size using a datagrid, and then return to frmSize and want to update the datagrid in frmSize to reflect the deletion. I can't figure out how to get the datagrid in frmSize updated, although the datagrid in frmSizeDelete shows the deletion properly. In frmSizeDelete the size is properly deleted when the user clicks the row in the datagrid and presses...
4
5351
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. Currently everything is working. I can find the updated rows/columns by parsing the posted data collection against the DataGrid DataSource. However, when there is a large amount of DataGridItems (rows) the update processing can take a while. ...
1
4313
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch the layout, some have child controls):
0
473
by: Steve | last post by:
I have a datagrid that is created at run time DataGrid dgG = new DataGrid(); BoundColumn bcB; dgG.CellPadding = 5; dgG.CellSpacing = 0; dgG.GridLines = GridLines.Both; dgG.CssClass = "SectionTableLines"; dgG.DataKeyField = "PlanWorkOrderID";
4
3487
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a snippet from my .css file: *************************** body { margin:0; padding:0;
5
2026
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated one row, all of them were updated so i immediatelly figured out that i have to include the id of every entry in the update statement. This is where the problem is raised. My database is an Access database. The table i am updating contains a Date...
5
2049
by: Tina | last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing validation elsewhere on the page. I want to specify that these buttons should not cause validation but they have no design time property of causevalidation. How can I keep them from causing validation? Thanks, T
17
2747
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only allow user to filter the first time, when they tried the second time, the speficied cast error message will prompt one.... I create a mydataset1 first, and the mydataset1 data source was getting from DataGrid.DataSource.
9
2714
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
0
8403
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
8737
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
8509
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
8610
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
7345
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...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
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
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.