.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 19th, 2003, 04:19 AM
mm1234 mm1234 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 mm1234 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry 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 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

Reply With Quote
  #2  
Old November 19th, 2003, 07:31 AM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
I have missed it...but do you open your connection to the database anywhere?

Reply With Quote
  #3  
Old November 19th, 2003, 07:44 AM
mm1234 mm1234 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 mm1234 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes, I do open a connection somewhere, actually since I've posted the problem i've been able to update my datasource, but as far as deleting/adding to the source...still doesn't work. I think it has something to do with the rowState not being able to change to either delete or insert on the datatable. I'm still stuck

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > updating db with dataAdapter/dataTable problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT