Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 19th, 2003, 06:49 AM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default updating db with dataAdapter/dataTable problem

I can't get seem to get this adapter(asp.net/vb) to update my msaccess db.

I am using an dataadapter to retrieve values from multiple tables using a stored query to fill a datatable (without a dataset) to bind to a datagrid. So far I can delete/add/update items in the datatable but when it's time to update the db(single table) I don't even get an error and my db does not show updated/deleted/new data. here is my code that retrieves and updates info from the db
:
Thank you for any help!!!!

dim dtPubTable as New DataTable("PubAuthors")
dim myAdapter as New OledbDataAdapter

sub filldgPubAuthors(pubID as integer)
Dim objConnection as new OledbConnection (ConfigurationSettings.AppSettings("StrConnection" ))
dim objCmd As New OleDbCommand()
Dim objParam As OleDbParameter
With objCmd
.Connection = objConnection
.CommandText = "[qryPubAuthorWeb]"
.CommandType = CommandType.StoredProcedure
objParam = .Parameters.Add("PublicationID", OleDbType.integer)

End With

objParam.Direction = ParameterDirection.Input
objParam.Value = pubID

Try

myAdapter = New OledbDataAdapter(objCmd)

addScema()
myAdapter.Fill(dtPubTable)
viewState("pubTable") = dtPUbTable

dgPubAuthors.dataSource = viewState("pubTable")
dgPubAuthors.databind()

Catch objError As Exception

labelError.Text = objError.Message

Finally

objConnection.Close()

end try


end sub

sub updateChild()
dtPubTable = cType(viewState("pubTable"),datatable)
dtPubTable.Columns.remove("Name")
dtPubTable.Columns.remove("PubRole")

dim strSQL as string = "SELECT tblPubAuthor.PubAuthorID, tblPubAuthor.PublicationID, tblPubAuthor.PubRoleID, tblPubAuthor.PersonID, tblPubAuthor.dlOrder, tblPubAuthor.Contribution " & _
"FROM tblPubAuthor " & _
"WHERE (((tblPubAuthor.PublicationID)=" & ViewState("hidPubID") & "));"

dim objCommand as new oledbCommand(strSQL,objConnection)
myAdapter.selectCommand = objCommand

Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(myAdapter)

myAdapter.Update(dtPubTable)

dtPubTable.AcceptChanges()

end sub



sub addScema()
dim tempRow as DataRow
tempRow = dtPubTable.NewRow()
tempRow("PUblicationID") = 1
tempRow("dlOrder") = 1
tempRow("Name") = getAuthorName()
tempRow("PersonID") = session("wwuID")
tempRow("PubRole") = "Author/CoAuthor"
tempRow("PubRoleId") = 1
tempRow("Contribution") = 1

dtPUbTable.Rows.add(tempRow)

viewState("pubTable") = dtPUbTable

else

dtPubTable = cType(viewState("pubTable"),datatable)

end if

end sub

Closed Thread


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
problem with updating the db using servlet Behl_Neha Java Databases 1 December 24th, 2007 06:08 AM
Updating Data Using DataAdapter ysebastian Classic ASP Databases 0 June 3rd, 2005 10:27 PM
Updating datatable Nikos General .NET 1 November 4th, 2004 04:43 PM
Datatable/DataView --> DataAdapter - ThX ! ank2go ADO.NET 4 April 28th, 2004 09:32 AM
ASP: Textarea Problem when updating DB seala Access ASP 1 June 13th, 2003 12:35 PM



All times are GMT -4. The time now is 12:04 PM.


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