Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 25th, 2006, 11:48 AM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Updating the record in database

Can you please help me.
Here is my code, it's not giving any error but it does not update the field in the database.

Dim strCnx As String = AccessCnx()
Dim strSQL As String = "SELECT * FROM Schedule"
Dim cnx As OleDbConnection = New OleDbConnection(strCnx)
cnx.Open()

Dim ds As Dataset = New DataSet
Dim sda as OleDbDataAdapter
sda= New OleDbDataAdapter(strSQL, cnx)
sda.Fill(ds, "Schedule")
Dim datarow1 As DataRow
Dim scb as OledbCommandBuilder = New OleDbCommandBuilder(sda)
sda.UpdateCommand = scb.GetUpdateCommand()

 For each datarow1 in ds.Tables("Schedule").Rows
  LL.Text=LL.Text & "<br>--" & datarow1("mo_ye") ' this line works OK
    datarow1.BeginEdit()
     datarow1("mo_ye")="33333" '??this line does not update the value
    datarow1.EndEdit()
  Next

 ds.AcceptChanges()
 sda.Update(ds, "Schedule")
 cnx.Close

Many thanks in advance.
 
Old February 27th, 2006, 11:22 AM
Authorized User
 
Join Date: Dec 2005
Location: bangalore, karnataka, India.
Posts: 77
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to g_vamsi_krish
Default

use try, catch. i think this will catch some exception.

vamsi
 
Old March 1st, 2006, 02:38 PM
Authorized User
 
Join Date: Mar 2005
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if you open the "Schedule" table,
what value is shown for "mo_ye"?

 
Old March 1st, 2006, 04:51 PM
Authorized User
 
Join Date: Mar 2005
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what I wanted to ask in the prior reply was,
you said: not updating the field in the database.

does the DataSet ds have the correct updates ?
because if ds is not correct then neither will your database.
bind and display ds to see what is in it.

could you explain this line to me ?
LL.Text=LL.Text & "<br>--" & datarow1("mo_ye")
I was wondering how the "mo_ye" works, does it identify a specific row?
 
Old March 8th, 2006, 09:40 AM
Authorized User
 
Join Date: Mar 2005
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Iwebzem, you have asked for help but you have not replied.
if you have solved your problem please let us know.
share your solution so other can benefit.

previously, i asked you to explain how this line "works" in your code.
LL.Text=LL.Text & "<br>--" & datarow1("mo_ye") ' this line works OK

you don't specify what is meant by "works"
i'll assume you mean the rows are identified in the string builder.

had you replied, next i would have asked you about "this line".
datarow1("mo_ye")="33333" '??this line does not update the value

i'll assume you mean the values in the DataRow.
this should work. however, i think all the values in your column will
be "33333".
that is, not just a value but all values.

is that what you mean by ".....not update the value" ?
if you want only a specific row to have "33333" you would need to specify an Index for that particular row.

lastly, if you mean the value or values in the DataSource are not
being updated, i would try removing the following line from your code.

ds.AcceptChanges()

hope this is of some help to you.
please respond when you ask for help!
many want to help but we don't want to waste time doing research, especially if you already got a solution. share it.




Similar Threads
Thread Thread Starter Forum Replies Last Post
updating database after record deletion marcstrong Visual Basic 2008 Essentials 1 July 22nd, 2008 05:25 PM
Updating database record shrisangeeta Classic ASP Basics 4 February 28th, 2007 05:25 PM
ASP.NET 2.0 Updating Database Record columth06 ASP.NET 2.0 Basics 0 November 4th, 2006 07:43 AM
Updating the record in the database lwebzem ASP.NET 1.0 and 1.1 Basics 3 February 28th, 2006 07:57 AM
Record not updating Tangerine ASP.NET 1.x and 2.0 Application Design 3 March 24th, 2004 12:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.