PC Review


Reply
Thread Tools Rate Thread

Database wont update but getting no errors....

 
 
=?Utf-8?B?QnJldHQ=?=
Guest
Posts: n/a
 
      20th Nov 2004
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_purchased",
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
 
Reply With Quote
 
 
 
 
james
Guest
Posts: n/a
 
      21st Nov 2004
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" <(E-Mail Removed)> wrote in message news:4BAEB06E-4FE1-47C5-90F1-(E-Mail Removed)...
> 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_purchased",
> 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



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      21st Nov 2004
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



 
Reply With Quote
 
=?Utf-8?B?QnJldHQ=?=
Guest
Posts: n/a
 
      21st Nov 2004
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" <(E-Mail Removed)> wrote in message news:4BAEB06E-4FE1-47C5-90F1-(E-Mail Removed)...
> > 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_purchased",
> > 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

>
>
>

 
Reply With Quote
 
=?Utf-8?B?QnJldHQ=?=
Guest
Posts: n/a
 
      21st Nov 2004
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
>
>
>
>

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      21st Nov 2004
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




 
Reply With Quote
 
=?Utf-8?B?QnJldHQ=?=
Guest
Posts: n/a
 
      21st Nov 2004
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 ?



"Cor Ligthert" wrote:

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

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      22nd Nov 2004
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
database wont update D Microsoft Dot NET 1 27th Jun 2008 07:57 PM
Database Switchboard Errors using 2003 Database on Access 2007 pete.trudell@twc.state.tx.us Microsoft Access 2 9th Apr 2008 01:35 PM
Database wont update from form =?Utf-8?B?U3R1Sm9s?= Microsoft Frontpage 4 9th Nov 2005 01:24 PM
windos update wont update and services wont work ither helpppppppppppp ryant Windows XP Help 0 9th Jun 2005 12:10 AM
System time wont update P4C800-E, seconds wont tick Ian Asus Motherboards 3 2nd Oct 2004 10:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:04 PM.