473,385 Members | 1,317 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,385 software developers and data experts.

datagridview will not update


I know this is a vague question, but I am not sure what information to give.
I am using VB2005 beta and the datagridview is pulling data from one of
three tables in an Access database. For some reason when I edit the feilds
that I have not set as readonly, the changes do not get written to the
database. I have the code that loads the datagridview posted below. Thanks
for any suggestions.

Thanks,

Thomas

Private Sub frmViewTables_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Variable used to track if the form is loading
'it will be used to keep some events from running
'when the form is loading

bolIsLoading = True
Me.Cursor = Cursors.WaitCursor
Me.Refresh()

'Set the form up based on which Table will be displayed
Select Case intDataTable
Case Is = 1
Me.LCMRTableAdapter.Fill(Me.TAMDataSet.LCMR)
Me.DataGridView1.DataSource = Me.TAMDataSet.LCMR
Me.Text = "LCMR DataTable"
Case Is = 2
Me.Q36TableAdapter.Fill(Me.TAMDataSet.Q36)
Me.DataGridView1.DataSource = Me.TAMDataSet.Q36
Me.Text = "Q36 DataTable"
Case Is = 3
Me.UTAMSTableAdapter.Fill(Me.TAMDataSet.UTAMS)
Me.DataGridView1.DataSource = Me.TAMDataSet.UTAMS
Me.Text = "UTAMS DataTable"
End Select

'Set up the header row
With DataGridView1.ColumnHeadersDefaultCellStyle
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(DataGridView1.Font, FontStyle.Bold)
End With

' Create a new cell style.
Dim style As New DataGridViewCellStyle
With style
.BackColor = Color.Beige
'.ForeColor = Color.Brown
End With

With DataGridView1
.EditMode = DataGridViewEditMode.EditOnEnter
.AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCells
.AutoSizeColumnsMode = _
DataGridViewAutoSizeColumnsMode.DisplayedCells
.ColumnHeadersBorderStyle = _
DataGridViewHeaderBorderStyle.Raised
.ColumnHeadersVisible = True
.CellBorderStyle = _
DataGridViewCellBorderStyle.Single
.GridColor = SystemColors.ActiveBorder
.AllowUserToAddRows = False
.AllowUserToOrderColumns = True
.AllowUserToResizeColumns = True
.BackgroundColor = Color.Honeydew

.Columns("DTG").DefaultCellStyle.Format = "dd-MMM-yy HH:mm:ss"
.Columns("Distance").DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleRight
.Columns("ID").ReadOnly = True
Select Case intDataTable
Case Is = 1
.Columns("Distance").ReadOnly = True
.Columns("Direction").ReadOnly = True
.Columns("RDistance").ReadOnly = True
.Columns("RDirection").ReadOnly = True
Case Is = 2
.Columns("Distance").ReadOnly = True
.Columns("Direction").ReadOnly = True
.Columns("RDistance").ReadOnly = True
.Columns("RDirection").ReadOnly = True
.Columns("Db").ReadOnly = True
.Columns("Velocity").ReadOnly = True
Case Is = 3

End Select
End With

' Apply the style as the default cell style.
DataGridView1.AlternatingRowsDefaultCellStyle = style

Me.Cursor = Cursors.Default
Me.Refresh()

'form has finished loading
bolIsLoading = False

End Sub

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Nov 21 '05 #1
3 11729
Thomas,

I see a lot of non relevant code for the update. However is there some code
to update as well?

Cor
<th*****@msala.net> schreef in bericht
news:43***********************@news.newsdemon.com. ..

I know this is a vague question, but I am not sure what information to
give.
I am using VB2005 beta and the datagridview is pulling data from one of
three tables in an Access database. For some reason when I edit the
feilds
that I have not set as readonly, the changes do not get written to the
database. I have the code that loads the datagridview posted below.
Thanks
for any suggestions.

Thanks,

Thomas

Private Sub frmViewTables_Load(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles MyBase.Load

'Variable used to track if the form is loading
'it will be used to keep some events from running
'when the form is loading

bolIsLoading = True
Me.Cursor = Cursors.WaitCursor
Me.Refresh()

'Set the form up based on which Table will be displayed
Select Case intDataTable
Case Is = 1
Me.LCMRTableAdapter.Fill(Me.TAMDataSet.LCMR)
Me.DataGridView1.DataSource = Me.TAMDataSet.LCMR
Me.Text = "LCMR DataTable"
Case Is = 2
Me.Q36TableAdapter.Fill(Me.TAMDataSet.Q36)
Me.DataGridView1.DataSource = Me.TAMDataSet.Q36
Me.Text = "Q36 DataTable"
Case Is = 3
Me.UTAMSTableAdapter.Fill(Me.TAMDataSet.UTAMS)
Me.DataGridView1.DataSource = Me.TAMDataSet.UTAMS
Me.Text = "UTAMS DataTable"
End Select

'Set up the header row
With DataGridView1.ColumnHeadersDefaultCellStyle
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(DataGridView1.Font, FontStyle.Bold)
End With

' Create a new cell style.
Dim style As New DataGridViewCellStyle
With style
.BackColor = Color.Beige
'.ForeColor = Color.Brown
End With

With DataGridView1
.EditMode = DataGridViewEditMode.EditOnEnter
.AutoSizeRowsMode = _
DataGridViewAutoSizeRowsMode.DisplayedCells
.AutoSizeColumnsMode = _
DataGridViewAutoSizeColumnsMode.DisplayedCells
.ColumnHeadersBorderStyle = _
DataGridViewHeaderBorderStyle.Raised
.ColumnHeadersVisible = True
.CellBorderStyle = _
DataGridViewCellBorderStyle.Single
.GridColor = SystemColors.ActiveBorder
.AllowUserToAddRows = False
.AllowUserToOrderColumns = True
.AllowUserToResizeColumns = True
.BackgroundColor = Color.Honeydew

.Columns("DTG").DefaultCellStyle.Format = "dd-MMM-yy HH:mm:ss"
.Columns("Distance").DefaultCellStyle.Alignment =
DataGridViewContentAlignment.MiddleRight
.Columns("ID").ReadOnly = True
Select Case intDataTable
Case Is = 1
.Columns("Distance").ReadOnly = True
.Columns("Direction").ReadOnly = True
.Columns("RDistance").ReadOnly = True
.Columns("RDirection").ReadOnly = True
Case Is = 2
.Columns("Distance").ReadOnly = True
.Columns("Direction").ReadOnly = True
.Columns("RDistance").ReadOnly = True
.Columns("RDirection").ReadOnly = True
.Columns("Db").ReadOnly = True
.Columns("Velocity").ReadOnly = True
Case Is = 3

End Select
End With

' Apply the style as the default cell style.
DataGridView1.AlternatingRowsDefaultCellStyle = style

Me.Cursor = Cursors.Default
Me.Refresh()

'form has finished loading
bolIsLoading = False

End Sub

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Nov 21 '05 #2

Well, that may be my problem. I thought that as long as the field was not
set to readonly and I had editonenter set that VB would handle the updating.
I was not aware that I needed to add code for the update to occur. Please
point me in the direction of what code I need to have the datagridview
update the database.

Thanks,

Thomas

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Nov 21 '05 #3
Thomas,

This is absolute not the right sample, however it shows you at least how to
update.

Better is of course to use an update button for an update. Than you have as
well to check for errors as by instance concurrency errors (that is if
somebody made changes in the maintime). However in my opinion is it nice to
see the basic. (The absolute most simple update version as there is, is at
the bottom).

This sample does a little bit it in the way as you thought it was working.

http://www.windowsformsdatagridhelp....7-5595f8147624

I hope this helps,

Cor

<th*****@msala.net> schreef in bericht
news:43**********************@news.newsdemon.com.. .

Well, that may be my problem. I thought that as long as the field was not
set to readonly and I had editonenter set that VB would handle the
updating.
I was not aware that I needed to add code for the update to occur. Please
point me in the direction of what code I need to have the datagridview
update the database.

Thanks,

Thomas

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

Nov 21 '05 #4

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

Similar topics

10
by: Henok Girma | last post by:
Hello Gurus, I want to save the state of an unbound DataGridView on my Windows Form application to an XML file so i can later load it back.. Basically, on my form I have a DataGridView, it's got...
0
by: TNSFED | last post by:
I have a dilemma when trying to delete a row from the DataGridView. Here is a sample of my code: private void dgv_EQUPS_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) {...
2
by: bob | last post by:
Can anyone tell me the best way to update a dataset while it is being edited/viewed in the DataGridView control? Is this something that should be inserted into one of the grid's events? or should...
11
by: Kevin | last post by:
I've been searching forever for examples of saving data changes in a DataGridView. There's all kinds of examples, but none really show how to save changes. Someone please help me. I have a...
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
2
by: Martin | last post by:
Hi all, This is the situation... DatagridView Control with datasource set to datatable. I want the user to be able to delete x number of rows by selecting a row with mouse then clicking a...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
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...
1
nev
by: nev | last post by:
Happy Easter to all! I have a problem with a datagridview. I placed code in a button click event as follows: dim dtt as datatable = dataset.employees.copy dtt.DefaultView.RowFilter = "='" &...
7
by: Bill Schanks | last post by:
VB.NET 2005 SQL Server 2000 I have a datagridview that users will update. When there are only a few records the update is fine. However when they update 100-200 of the rows the udpate can take...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.