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

Database wont update but getting no errors....

Not sure what the problem is here... Trying to update from a datagrid to an
access database using vb.net... Its not updating the database but Im not
getting any errors... Here is my code...

'OleDbUpdateCommand1

Me.OleDbUpdateCommand1.CommandText = "UPDATE tblGifts SET gift = ?,
name = ?, purchased = ? WHERE (autonum = ?) AND (gi" & _
"ft = ? OR ? IS NULL AND gift IS NULL) AND (name = ? OR ? IS NULL
AND name IS NUL" & _
"L) AND (purchased = ?)"
Me.OleDbUpdateCommand1.Connection = Me.OleDbConnection1
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("gift",
System.Data.OleDb.OleDbType.VarWChar, 50, "gift"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("name",
System.Data.OleDb.OleDbType.VarWChar, 50, "name"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("purchased",
System.Data.OleDb.OleDbType.Boolean, 2, "purchased"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_autonum ",
System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "autonum",
System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_gift",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_gift1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_name",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_name1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_purchas ed",
System.Data.OleDb.OleDbType.Boolean, 2, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "purchased",
System.Data.DataRowVersion.Original, Nothing))

--------------------------------------------------------------------------

Sub dgGifts_Update(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
Dim ckPurchased As CheckBox = CType(e.Item.FindControl("CheckBox1"),
CheckBox)
Me.OleDbConnection1.Open()
daGifts.Update(DsGifts1)
Me.OleDbConnection1.Close()
dgGifts.EditItemIndex = -1
daGifts.Fill(DsGifts1)
dgGifts.DataBind()
End Sub

--------------------------------------------------------

Any help would be appreciated... Thanks :-)
-Brett
Nov 21 '05 #1
6 1700
I see where you are telling the DataAdaptor to Update: daGifts.Update(DsGifts1) < I'm assuming DsGifts1 is your Dataset>
But, you are not telling it which Table to update: daGifts.Update(DsGifts1,"tblGifts") < and I assume that tblGifts is the
table you want to update.>
That appears to me to be the problem. Although, I would think it would throw an error if you doin't specify the table to apply
the update to.
james

"Brett" <Br***@discussions.microsoft.com> wrote in message news:4B**********************************@microsof t.com...
Not sure what the problem is here... Trying to update from a datagrid to an
access database using vb.net... Its not updating the database but Im not
getting any errors... Here is my code...

'OleDbUpdateCommand1

Me.OleDbUpdateCommand1.CommandText = "UPDATE tblGifts SET gift = ?,
name = ?, purchased = ? WHERE (autonum = ?) AND (gi" & _
"ft = ? OR ? IS NULL AND gift IS NULL) AND (name = ? OR ? IS NULL
AND name IS NUL" & _
"L) AND (purchased = ?)"
Me.OleDbUpdateCommand1.Connection = Me.OleDbConnection1
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("gift",
System.Data.OleDb.OleDbType.VarWChar, 50, "gift"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("name",
System.Data.OleDb.OleDbType.VarWChar, 50, "name"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("purchased",
System.Data.OleDb.OleDbType.Boolean, 2, "purchased"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_autonum ",
System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "autonum",
System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_gift",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_gift1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_name",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_name1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_purchas ed",
System.Data.OleDb.OleDbType.Boolean, 2, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "purchased",
System.Data.DataRowVersion.Original, Nothing))

--------------------------------------------------------------------------

Sub dgGifts_Update(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
Dim ckPurchased As CheckBox = CType(e.Item.FindControl("CheckBox1"),
CheckBox)
Me.OleDbConnection1.Open()
daGifts.Update(DsGifts1)
Me.OleDbConnection1.Close()
dgGifts.EditItemIndex = -1
daGifts.Fill(DsGifts1)
dgGifts.DataBind()
End Sub

--------------------------------------------------------

Any help would be appreciated... Thanks :-)
-Brett

Nov 21 '05 #2
Brett,

Are you sure there is something to update.

Standard you can write
if DSGifts1.haschanges then
daGifts.Fill(DsGifts1)
end if

Than you can as well easily debug that.

I hope this helps?

Cor

Nov 21 '05 #3
Hmmm.... It makes sense to me that the table would have to be included, but
it still does the same thing. Per Cors comment, it looks like there may not
be anything to update cause when using his code it doesnt fill the dataset
again... I dont understand why though, cause I AM making a change to the
datagrid.... Any ideas??

"james" wrote:
I see where you are telling the DataAdaptor to Update: daGifts.Update(DsGifts1) < I'm assuming DsGifts1 is your Dataset>
But, you are not telling it which Table to update: daGifts.Update(DsGifts1,"tblGifts") < and I assume that tblGifts is the
table you want to update.>
That appears to me to be the problem. Although, I would think it would throw an error if you doin't specify the table to apply
the update to.
james

"Brett" <Br***@discussions.microsoft.com> wrote in message news:4B**********************************@microsof t.com...
Not sure what the problem is here... Trying to update from a datagrid to an
access database using vb.net... Its not updating the database but Im not
getting any errors... Here is my code...

'OleDbUpdateCommand1

Me.OleDbUpdateCommand1.CommandText = "UPDATE tblGifts SET gift = ?,
name = ?, purchased = ? WHERE (autonum = ?) AND (gi" & _
"ft = ? OR ? IS NULL AND gift IS NULL) AND (name = ? OR ? IS NULL
AND name IS NUL" & _
"L) AND (purchased = ?)"
Me.OleDbUpdateCommand1.Connection = Me.OleDbConnection1
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("gift",
System.Data.OleDb.OleDbType.VarWChar, 50, "gift"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("name",
System.Data.OleDb.OleDbType.VarWChar, 50, "name"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("purchased",
System.Data.OleDb.OleDbType.Boolean, 2, "purchased"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_autonum ",
System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "autonum",
System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_gift",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_gift1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_name",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_name1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_purchas ed",
System.Data.OleDb.OleDbType.Boolean, 2, System.Data.ParameterDirection.Input,
False, CType(0, Byte), CType(0, Byte), "purchased",
System.Data.DataRowVersion.Original, Nothing))

--------------------------------------------------------------------------

Sub dgGifts_Update(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
Dim ckPurchased As CheckBox = CType(e.Item.FindControl("CheckBox1"),
CheckBox)
Me.OleDbConnection1.Open()
daGifts.Update(DsGifts1)
Me.OleDbConnection1.Close()
dgGifts.EditItemIndex = -1
daGifts.Fill(DsGifts1)
dgGifts.DataBind()
End Sub

--------------------------------------------------------

Any help would be appreciated... Thanks :-)
-Brett


Nov 21 '05 #4
Cor

See response to james.... :-)

"Cor Ligthert" wrote:
Brett,

Are you sure there is something to update.

Standard you can write
if DSGifts1.haschanges then
daGifts.Fill(DsGifts1)
end if

Than you can as well easily debug that.

I hope this helps?

Cor

Nov 21 '05 #5
Brett,

I saw but have not the idea you showed where/how you did the update of items
in the rows of a table in the dataset.

The most known problem is that the data is not yet forced in the datset
because of a row change (currencymanager), that you can do with

BindingContext(ds.Tables(0)).EndCurrentEdit()

I hope this helps a little bit?

Cor


Nov 21 '05 #6
Brett
Im not sure I know what you mean. Im fairly new to .NET, so you'll have to
bear with my ignorance. :-) Shouldnt the dataset be updated because of the
update parameters ?

Yes the should, however there should be data to update.

Do you know the commandbuilder by the way, for the not to difficult select
statements (less than 100 fields and no joins) it makes mostly your
commands.

dim cmb as new commandbuilder(da)
http://msdn.microsoft.com/library/de...edcommands.asp

I hope this helps?

Cor
Nov 21 '05 #7

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

Similar topics

2
by: lawrence | last post by:
A very strange bug. www.monkeyclaus.org is run by a cms I'm developing. One of types of users we allow is "justTestingTheSite", a type of user I developed to give demo's to prospective clients. The...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
2
by: TJ | last post by:
Hi All, I am having some trouble. I have created a database via the new database option inside VWD2005. Then and table or two. I have been able to perform INSERT and SELECT operations on...
3
by: Arthur Dent | last post by:
Hello All,.. I have some settings stored in the project settings which show up under My.Settings. ... All works fine. Now, I wanted to change the value of one of these settings, so I went...
1
by: Muchach | last post by:
Hello, Ok so what I've got going on is a form that is populated by pulling info from database then using php do{} to create elements in form. I have a text box in each table row for the user to...
6
by: Suresh | last post by:
Hi All, I am fetching a dataset from the database under some condition. After this I create a data table. Traverse in the original dataset & add each row to created data table as it is through...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
Private Sub UpdateTblHistory() Dim strSql As String strSql = "Update tbl_History set SubscrID = @SubscrID Where ID = @ID" da.UpdateCommand.CommandText = strSql...
1
by: D | last post by:
I am trying to add records to a database and getting no errors but the databse is not updated. Not sure what is wrong maybe in my function I'm losing some thing? What do you think? My code is...
0
by: imusion | last post by:
Hi, I have 2 servers each running AIX and both have a DB2 database setup on them. I'm building a news management application and in our setup we need to have a staging and production setup. So...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
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
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
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...
0
tracyyun
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...
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.