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 10 1379
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
Hi Cor... Thanks for the response....
Doesnt the datasource get updated by the executenonquery??
If not, How would I go about setting it?
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
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??
Anonymous,
Just try it, I assume that this can be (one) of the reasons you don't see
the right information.
Cor
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)
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 -----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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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,...
|
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):
|
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";
| |
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;
|
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...
|
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
|
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...
|
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...
|
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...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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. ...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
| |