Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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.
  #2 (permalink)  
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
  #3 (permalink)  
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"?

  #4 (permalink)  
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?
  #5 (permalink)  
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.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.