473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Insert, Update, Delete through DataGrid

From what I can gather these commands are automatically
generated throught the OleDbDataAdapter wizard when
working with a one table database and from the MSDN
documnetation the values shown on screen are only a
snapshot of the data stored in the datbase not the actual
data itself. I just can't figure out what code I need in
the click event of my corosponding command buttons to
perform these actions. I presume I need to open, write
and close the database but at this point I'm lost any
help is much appreciated.

Thanks G.N
Nov 20 '05 #1
7 7263
Hello Gary

basically...these are the steps:

1. Fill Datatable using DataAdapter
2. Set DataTable as datasource for grid
3. User makes changes to various rows, maybe adds new row, deletes another,
etc
4. Use update method of DataAdapter to update changes to DataTable


--
Ibrahim Malluf
http://www.malluf.com
==============================================
MCS Data Services Code Generator
http://64.78.34.175/mcsnet/DSCG/Announcement.aspx
==============================================

"Garry Newman" <G.**********@hotmail.com> wrote in message
news:10*****************************@phx.gbl...
From what I can gather these commands are automatically
generated throught the OleDbDataAdapter wizard when
working with a one table database and from the MSDN
documnetation the values shown on screen are only a
snapshot of the data stored in the datbase not the actual
data itself. I just can't figure out what code I need in
the click event of my corosponding command buttons to
perform these actions. I presume I need to open, write
and close the database but at this point I'm lost any
help is much appreciated.

Thanks G.N

Nov 20 '05 #2
Garry if you set the 'read only' property of the DataDrid
to 'False' then you can use something like...

OleDbDataAdapter1.Update(DataSet1)

from your command button to save any changes you've made
during run-time.

To delete a record you can simply highlight the record
and hit delete on your keyboard likewise to add a record
you can just tab on or mouse click in the last record in
your datagrid which will appear blank and marked with an
* but I don't know how to get this add and delete
function running from command buttons, but I'm sure one
of the experts here will point you in the right direction
when they read your post...

Regards Steve
Nov 20 '05 #3
Thanks Ibrahim

All these things steps you've highlighted work perfectly
well but all I want is a command button which deletes a
record and one that starts a new record (the typical
controls you would have on an Access form instead of
having to highlight the record and hit delete on keyboard
or click on blank row to activate new record

Thanks G.N
Nov 20 '05 #4
ok thanks Steve at least I can get my ammendments to save
now, but I'd really like 'Add' & 'Delete' buttons on my
form instead of having to do it manually...

Thanks GN
Nov 20 '05 #5
Cor
Hi Garry,

There are a lot of possibilities how to do what your ask.

This is an example of a delete with a button, but it depends how you did
other things if it will work for you. We don't see code of you, do you know.
But this works for me.

\\\
Private Sub btnDelete_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnDelelete.Click
dataset1.Tables(0).Rows(datagrid1.CurrentRowIndex) .Delete()
End Sub
///

But basicly I think this is what you are looking for?

Cor
All these things steps you've highlighted work perfectly
well but all I want is a command button which deletes a
record and one that starts a new record (the typical
controls you would have on an Access form instead of
having to highlight the record and hit delete on keyboard
or click on blank row to activate new record

Thanks G.N

Nov 20 '05 #6
Thanks Cor

That worked fine...
Nov 20 '05 #7
Thanks Cor

That worked fine

G.N
Nov 20 '05 #8

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

Similar topics

16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
0
by: 4 | last post by:
Insert/Delete/Modify Statement Shortcuts??? Help!! I am working in C# and running an Oracle 9i server. I was just wonering if there is a shortcut way of updating my tables and not have to...
0
by: Christopher | last post by:
I AM GETTING A SYSTEM.DATA.SQLCLIENT.SQLEXCEPTION ERROR WHEN ATTEMPTING TO INSERT DATA INTO A SINGLE TABLE THROUGH A GRID //If this is due to a spelling error, i will //inflict a ritual...
2
by: Mark | last post by:
I have a repetitive task where I need to edit a table in SQL Server through a web page. Nothing fancy, just populate a datagrid and use the commands Insert/Update/Delete/Cancel. Is there a...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
1
by: Primillo | last post by:
'Full source 'Insert, delete and update don't work Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents...
4
by: drakuu | last post by:
Hello there, I have DataGrid with some records and I would like to edit it right in the datagrid using the built in commands. I can't figure out a way to pass to the SQL query the record ID...
0
by: debnath1981 | last post by:
Insert, Update, Delete through DataGrid
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.