469,902 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

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 1571
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Arthur Dent | last post: by
1 post views Thread by Muchach | last post: by
6 posts views Thread by Suresh | last post: by
1 post views Thread by =?Utf-8?B?UmljaA==?= | last post: by
1 post views Thread by D | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.