473,756 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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...

'OleDbUpdateCom mand1

Me.OleDbUpdateC ommand1.Command Text = "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.OleDbUpdateC ommand1.Connect ion = Me.OleDbConnect ion1
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("gift",
System.Data.Ole Db.OleDbType.Va rWChar, 50, "gift"))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("name",
System.Data.Ole Db.OleDbType.Va rWChar, 50, "name"))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("purchased" ,
System.Data.Ole Db.OleDbType.Bo olean, 2, "purchased" ))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_au tonum",
System.Data.Ole Db.OleDbType.In teger, 0, System.Data.Par ameterDirection .Input,
False, CType(0, Byte), CType(0, Byte), "autonum",
System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_gi ft",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_gi ft1",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_na me",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_na me1",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_pu rchased",
System.Data.Ole Db.OleDbType.Bo olean, 2, System.Data.Par ameterDirection .Input,
False, CType(0, Byte), CType(0, Byte), "purchased" ,
System.Data.Dat aRowVersion.Ori ginal, Nothing))

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

Sub dgGifts_Update( ByVal sender As Object, ByVal e As
DataGridCommand EventArgs)
Dim ckPurchased As CheckBox = CType(e.Item.Fi ndControl("Chec kBox1"),
CheckBox)
Me.OleDbConnect ion1.Open()
daGifts.Update( DsGifts1)
Me.OleDbConnect ion1.Close()
dgGifts.EditIte mIndex = -1
daGifts.Fill(Ds Gifts1)
dgGifts.DataBin d()
End Sub

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

Any help would be appreciated... Thanks :-)
-Brett
Nov 21 '05 #1
6 1728
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,"tblGi fts") < 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***@discussi ons.microsoft.c om> wrote in message news:4B******** *************** ***********@mic rosoft.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...

'OleDbUpdateCom mand1

Me.OleDbUpdateC ommand1.Command Text = "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.OleDbUpdateC ommand1.Connect ion = Me.OleDbConnect ion1
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("gift",
System.Data.Ole Db.OleDbType.Va rWChar, 50, "gift"))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("name",
System.Data.Ole Db.OleDbType.Va rWChar, 50, "name"))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("purchased" ,
System.Data.Ole Db.OleDbType.Bo olean, 2, "purchased" ))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_au tonum",
System.Data.Ole Db.OleDbType.In teger, 0, System.Data.Par ameterDirection .Input,
False, CType(0, Byte), CType(0, Byte), "autonum",
System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_gi ft",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_gi ft1",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_na me",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_na me1",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_pu rchased",
System.Data.Ole Db.OleDbType.Bo olean, 2, System.Data.Par ameterDirection .Input,
False, CType(0, Byte), CType(0, Byte), "purchased" ,
System.Data.Dat aRowVersion.Ori ginal, Nothing))

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

Sub dgGifts_Update( ByVal sender As Object, ByVal e As
DataGridCommand EventArgs)
Dim ckPurchased As CheckBox = CType(e.Item.Fi ndControl("Chec kBox1"),
CheckBox)
Me.OleDbConnect ion1.Open()
daGifts.Update( DsGifts1)
Me.OleDbConnect ion1.Close()
dgGifts.EditIte mIndex = -1
daGifts.Fill(Ds Gifts1)
dgGifts.DataBin d()
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.hascha nges then
daGifts.Fill(Ds Gifts1)
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,"tblGi fts") < 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***@discussi ons.microsoft.c om> wrote in message news:4B******** *************** ***********@mic rosoft.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...

'OleDbUpdateCom mand1

Me.OleDbUpdateC ommand1.Command Text = "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.OleDbUpdateC ommand1.Connect ion = Me.OleDbConnect ion1
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("gift",
System.Data.Ole Db.OleDbType.Va rWChar, 50, "gift"))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("name",
System.Data.Ole Db.OleDbType.Va rWChar, 50, "name"))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("purchased" ,
System.Data.Ole Db.OleDbType.Bo olean, 2, "purchased" ))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_au tonum",
System.Data.Ole Db.OleDbType.In teger, 0, System.Data.Par ameterDirection .Input,
False, CType(0, Byte), CType(0, Byte), "autonum",
System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_gi ft",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_gi ft1",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"gift", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_na me",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_na me1",
System.Data.Ole Db.OleDbType.Va rWChar, 50,
System.Data.Par ameterDirection .Input, False, CType(0, Byte), CType(0, Byte),
"name", System.Data.Dat aRowVersion.Ori ginal, Nothing))
Me.OleDbUpdateC ommand1.Paramet ers.Add(New
System.Data.Ole Db.OleDbParamet er("Original_pu rchased",
System.Data.Ole Db.OleDbType.Bo olean, 2, System.Data.Par ameterDirection .Input,
False, CType(0, Byte), CType(0, Byte), "purchased" ,
System.Data.Dat aRowVersion.Ori ginal, Nothing))

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

Sub dgGifts_Update( ByVal sender As Object, ByVal e As
DataGridCommand EventArgs)
Dim ckPurchased As CheckBox = CType(e.Item.Fi ndControl("Chec kBox1"),
CheckBox)
Me.OleDbConnect ion1.Open()
daGifts.Update( DsGifts1)
Me.OleDbConnect ion1.Close()
dgGifts.EditIte mIndex = -1
daGifts.Fill(Ds Gifts1)
dgGifts.DataBin d()
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.hascha nges then
daGifts.Fill(Ds Gifts1)
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 (currencymanage r), that you can do with

BindingContext( ds.Tables(0)).E ndCurrentEdit()

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
2935
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 purpose of this level of security is to let someone log in and see everything as if they were root, and yet not be able to update or delete anything, as they have no real priveledges at all. I just logged in as root and created such an...
0
5827
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 which indexes computer magazine articles for personal reference. I am developing a Visual Basic.NET program whose sole purpose is to enter new records into the database. No updates to existing entries, no deletions, and no display
2
4173
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 the table, BUT cannot do an UPDATE. After the update command it says 1 row updated, but the data does not change. At one point I receieved a message stating something like (heavily paraphrased...):
3
3011
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 into the app.config file, and changed the value, and reran the app. But it still picks up the old value, and doesn't pay attention to the new value which I entered in the app.config file.
1
2825
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 enter input. I need to take this user input and put it back into the database. What would be the best method to do this. I can't use a normal post because the name of the text box is the same for each table row. I've heard that posting the...
6
3800
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 LoadDataRow method. After adding the row I just update 4-5 columns out of 20 columns in the row. After entire looping I fire the AcceptChanges method on data table. After this I am trying to update this data back to database in two ways - 1) Merge...
1
1631
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 da.UpdateCommand.Parameters.Add("@SubscrID", SqlDbType.VarChar, 50, "SubscrID") da.UpdateCommand.Parameters.Add("@ID", SqlDbType.Int, 4, "ID") da.Update(ds, "tbl_History")
1
1238
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 below. Thanks using System; using System.Collections.Generic; using System.ComponentModel;
0
2904
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 the staging database gets the changes performed and then once we're satisfied with how it looks, we push the changes through SQL queries which perform the (deletions, updating, and inserting of articles) onto the production database by comparing it to...
0
9455
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, 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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9869
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8709
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5140
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2665
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.