Hello
I can't get my update command to work..
I've used the sqlDataAdapter wizard to create a dataAdapter sqlDA_CB_LP, and it created the 'UPDATE' code as follows
Me.sqlDA_CB_LP.UpdateCommand = Me.SqlUpdateCommand
Me.SqlUpdateCommand4.Connection = Me.SqlConnection
Me.SqlUpdateCommand4.Parameters.Add(New System.Data.SqlClient.SqlParameter("@STR_COMMENT", System.Data.SqlDbType.NVarChar, 1073741823, "STR_COMMENT")
In my sub that populates the form
cbLP = New SqlCommandBuilder(sqlDA_CB_LP
dsCBLP1.clear(
sqlDA_CB_LP.fill(dsCBLP1
dvCB_LP = New Datavie
with dvCB_L
.table = dsCBLP1.Tables("TDT_CUT_BLOCK_LP"
.RowFilter = "ID_CUT_BLOCK = '" & txtBlockID.Text & "'
End Wit
Me.txtLPComm.DataBindings.Add("text", dvCB_LP, "STR_COMMENT"
Then under my "Save" button
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles btnSave.Clic
Tr
sqlDA_CB_LP.Update(DsCBLP1, "TDT_CUT_BLOCK_LP"
Catch ex As Exceptio
MessageBox.Show(ex.Message
End Tr
End Su
But, it doesn't work..
Any ideas what I'm doing wrong?
Thanks
Ambe 2 960
Hi Amber:
"amber" <an*******@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.com... Hello, I can't get my update command to work...
I've used the sqlDataAdapter wizard to create a dataAdapter sqlDA_CB_LP,
and it created the 'UPDATE' code as follows: Me.sqlDA_CB_LP.UpdateCommand = Me.SqlUpdateCommand4 Me.SqlUpdateCommand4.Connection = Me.SqlConnection1
Me.SqlUpdateCommand4.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@STR_COMMENT",
System.Data.SqlDbType.NVarChar, 1073741823, "STR_COMMENT"))
In my sub that populates the form:
cbLP = New SqlCommandBuilder(sqlDA_CB_LP) dsCBLP1.clear() sqlDA_CB_LP.fill(dsCBLP1) dvCB_LP = New Dataview
with dvCB_LP .table = dsCBLP1.Tables("TDT_CUT_BLOCK_LP") .RowFilter = "ID_CUT_BLOCK = '" & txtBlockID.Text & "'" End With
Me.txtLPComm.DataBindings.Add("text", dvCB_LP, "STR_COMMENT")
Then under my "Save" button: Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
EventArgs) Handles btnSave.Click
What exactly do you mean when you say it 'doesn't work'? There can be a few
things. The first thing to do is verify that you have changes in your
dataset, if you don't, calling update 10000000 times won't do a thing. So,
right before the Update command, insert this:
Debug.Assert(DsCBLP1.HasChanges)
Now, if you get a big ugly messagebox popping up, the problem is that you
don't have any changes in the DB. You may need to call EndCurrentEdit or
one of a few other things... So verify the HasChanges first and we'll
eliminate things from there.
Next, are you gettting an exception or is it just not updating the changes
in the DB?
Another thing, if you use the COnfiguration wizard, it should gen the logic
for you for the Update/Delete/Insert statements. you don't need a
commandbuilder and you don't want to use it if you already have your logic
in place. When you ran the configuration wizard, did it tell you that it
succesfully created the Update/Insert/Delete commands? If you don't have a
key for instance, it won't work but neither will the CommandBuilder -
although it should throw an exception.
Let me know about these and we'll take it from there.
Cheers,
Bill Try sqlDA_CB_LP.Update(DsCBLP1, "TDT_CUT_BLOCK_LP") Catch ex As Exception MessageBox.Show(ex.Message) End Try
End Sub
But, it doesn't work... Any ideas what I'm doing wrong??
Thanks, Amber
Hi Bill
Thanks for your help :
I added the "debug.assert()" line, and it did come up with an error...so I guess there is nothing to update
I did run the wizard, and it did generate all the sql commands
I've been battling this for a while, and was told I had to add the 'commandbuilder' line..
Does it have anything to do with the fact that I'm using a dataview, of a dataset, then trying to update the dataset
What I have is a form that has text fields populated (by this dataview) from a SQL database. I'm changing the text in them to trigger a 'change' so the update command will work
A 'save' button calls the update method
Any ideas?
Thank
ambe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jason |
last post by:
Let's say I have an html form with 20 or 30 fields in it. The form
submits the fields via POST to a php page which updates a table in a
database with the $_POST vars. Which makes more sense?
...
|
by: gaosul |
last post by:
I am non-programming scientist and I am using a Program called
Easyarticles from Synaptosoft Inc., which is based the database
program Access. Unfortunately, the owner of this company has...
|
by: Bucko |
last post by:
How important do you guys feel locking a database is while
updating/adding information? Do you do it with every app you make? Only
very high volume (traffic) apps? I'm trying to decide if my app...
|
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...
|
by: Luis Esteban Valencia |
last post by:
Hello Everyone,
Iam an intermediate ASP.Net programmer and iam facing a challenging task.
I have a table in MS-SQL server database called 'Members'. The table has
following fields...
...
|
by: |
last post by:
Hello,
I have created an ASP.NET 2.0 application that utilized a Gridview Control
to display and update/delete data.
The problem I am having is that the gridview control is displaying the data...
|
by: jaYPee |
last post by:
does anyone experienced slowness when updating a dataset using
AcceptChanges?
when calling this code it takes many seconds to update the database
SqlDataAdapter1.Update(DsStudentCourse1)...
|
by: Alexey.Murin |
last post by:
The application we are developing uses MS Access 2003 database (with
help of ADO).
We have noticed that during massive records updating the size of the
mdb file increases dramatically (from 3-4 to...
|
by: Geoff |
last post by:
Hi
I'm hoping somebody can help me with the following problem that has occurred
to me.
Suppose I have two tables in an SQL Server database. Let's call these tables
A and B. Assume that A has...
|
by: jonbartlam |
last post by:
Hi There
I'm not sure what exactly is going wrong here. I'm writing an application that retreives a table from a database (tbl_internalfaults) and updates it. (Actually, just the status column will...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |