codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Deleting from database (ms. Access)  hot_choc at 21:32 on Thursday, April 21, 2005
 

Hie, i'm still kind of new using ASP.NET. i'm doing this project using vb.net coding and Microsoft Access as database. my function is suppose to delete the record from the database, by referring to the information that is shown in a label control. here is my coding:

dsSchedule.Schedule.Clear()
daSchedule.Fill(dsSchedule)
Dim dr As DataRow
Dim tobefound As String
tobefound = lbleight.Text
For Each dr In dsSchedule.Tables("Schedule").Rows
If dr.Item("Title") = tobefound Then
dr.Delete()

Exit For
End If
Next
daSchedule.Update(dsSchedule)
dsSchedule.AcceptChanges()

it's suppose to delete the whole row that contains that title. but it doesn't work. when i click the button, it refreshes the page and the label is cleared. but it will appear again if i click another button. it doesn't have any error message either. anything wrong with my code? thanks.

  Re: Deleting from database (ms. Access)  namtdo at 10:50 on Wednesday, May 04, 2005
 

try to use OleDbDataAdapter and OleDbCommandBuilder for updating.


ex:
Public Sub updateDataSet(ByRef aDataSet As DataSet, ByVal dsName As String)
Try
adapter.DeleteCommand = builder.GetDeleteCommand()
adapter.InsertCommand = builder.GetInsertCommand()
adapter.UpdateCommand = builder.GetUpdateCommand()
adapter.Update(aDataSet, dsName)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  do static member are inherited
•  Re: Help with Using DataReader with StoredProcedure
•  Perl Script Output (w3c validator)
•  Re: HashMap question
•  focus management?
•  Looping Issue...Please help!
•  regarding hibernate
•  working with plugins
•  Checkbox Validation help.


Recent Articles
What is a pointer in C?
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net


© Copyright codetoad.com 2001-2006