473,405 Members | 2,210 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,405 software developers and data experts.

Datagrid Update problem

Hello... Im having a problem getting a datagrid to update.
Everything in my code looks ok so Im at a loss. I can
click update and the grid will rebind... but not with my
updated data. I am not posting back in pageload... And its
not database permissions cause I can do inserts. Please
Help! here is my code:

Sub dgStaff_Update(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
'Get values out of the datagrid to update
Dim intID As Integer = e.Item.Cells(0).Text
Dim strGrp As String = e.Item.Cells(1).Text
Dim nameTextBox As TextBox = e.Item.Cells
(2).FindControl("txtDGName")
Dim posTextBox As TextBox = e.Item.Cells
(3).FindControl("txtDGPos")
Dim numTextBox As TextBox = e.Item.Cells
(4).FindControl("txtDGNum")
Dim strSql As String = "UPDATE tbl_parishstaff Set
person=@person, pos=@pos, num=@num WHERE id=@id"

'Create new update object and add parameters
Dim updateClergyStaff As OleDb.OleDbCommand = New
OleDb.OleDbCommand(strSql, Me.OleDbConnection1)

updateClergyStaff.Parameters.Add("@id", intID)
updateClergyStaff.Parameters.Add("@grp", strGrp)
updateClergyStaff.Parameters.Add("@person",
nameTextBox.Text)
updateClergyStaff.Parameters.Add("@pos",
posTextBox.Text)
updateClergyStaff.Parameters.Add("@num",
numTextBox.Text)
'Open the database, update the data, close
database.
updateClergyStaff.Connection.Open()
updateClergyStaff.ExecuteNonQuery()
Response.Write(updateClergyStaff.ExecuteNonQuery.)
updateClergyStaff.Connection.Close()

'After updating data fill grid with updated info
and return to normal state
dgStaff.EditItemIndex = -1
daStaff.Fill(DsStaff1)
dgStaff.DataBind()
End Sub
Nov 22 '05 #1
10 1374
Brett,

I see a lot, however what I don't see is where you set that new readed
dataset to your datagrid as a datasource?

Cor

Nov 22 '05 #2
Hi Cor... Thanks for the response....

Doesnt the datasource get updated by the executenonquery??
If not, How would I go about setting it?
Nov 22 '05 #3
Brett,

I see that you do this.
dgStaff.EditItemIndex = -1
daStaff.Fill(DsStaff1)
dgStaff.DataBind()


I assume that that is your dataset so I would expect a
dgStaff.Datasource = DsStaff

Or something there

Cor
Nov 22 '05 #4
Hi Cor...

dgStaff.Datasource = dsStaff1 is already being done in a
prior statement. The datagrid does fill, just not with my
updated data. Unless I need to refill it?? Do I need it in
a different spot maybe? THis one is driving me nuts, as I
dont really see anything wrong??
Nov 22 '05 #5
Anonymous,

Just try it, I assume that this can be (one) of the reasons you don't see
the right information.

Cor
Nov 22 '05 #6
Facetious,

Tried it... same thing... :-(

Whats strange is that if i response.write the parameters
passed in they print out correctly (showing my changes).
So its got to be somewhere in the update itself??? Or in
the binding somewhere???

-Frustrated (Brett)
Nov 22 '05 #7
Brett,

I don't understand your message. Is your actual database updated or is that
not?

What would than be strange that there is than not an error throwed when it
is not.

Cor
Nov 22 '05 #8
-----Original Message-----
Brett,

I don't understand your message. Is your actual database updated or is thatnot?

What would than be strange that there is than not an error throwed when itis not.

Cor

Cor,

Correct, The database is not getting updated. I would
think there should be an error too... but I hit update,
and the dataset rebinds to the grid without the updated
data... Strange :-( This is my first attempt at an update,
but from examples I have seen everthing looks to be in
place.

-Brett

Nov 22 '05 #9
Brett,
updateClergyStaff.ExecuteNonQuery()
Response.Write(updateClergyStaff.ExecuteNonQuery.)
updateClergyStaff.Connection.Close()

What is that Response.Write a strange instruction espicaly that dot

I never did it this way, however can you change that for
\\\
try
updateClergyStaff.ExecuteNonQuery
catch ex as exception
response.redirect(ex.toString)
finally
updateClergyStaff.Connection.Close()
end try

///
Even when it was only to try now.

Cor
Nov 22 '05 #10

lol... oopss... that shouldnt be in there... That was a
pasted in response.write that somehow has the
executenonquery in it. sorry bout that./

-Brett
Nov 22 '05 #11

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

Similar topics

2
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...
9
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...
4
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. ...
1
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...
0
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 =...
4
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...
5
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...
5
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...
17
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...
9
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...
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?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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,...
0
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...

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.