Results 1 to 6 of 6

Thread: Best way to add, update, and delete a database [* Resolved *]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Best way to add, update, and delete a database [* Resolved *]

    Hello,

    I have a database application and have been experiencing problems adding, updating, and deleting using the data table.
    Is there a more efficient and robust way to do this. My code l have used is listed below. Someone told me it is better to use the dataset rather than the datatable. If this is so would it be possible to convert the below code to using the dataset. I am not sure on how to use the syntax.

    Code:
    cnnTeacher.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\IBS Library System\LibrarySystem.mdbersist Security Info=False"; 
    OleDbDataAdapter daTeacher = new OleDbDataAdapter("SELECT * FROM Teacher",cnnTeacher);
    OleDbCommandBuilder cbTeacher = new OleDbCommandBuilder(daTeacher);
    daTeacher.Fill(dtTeacher);
    
    DataRow drNewTeacher = dtTeacher.NewRow();
    
    drNewTeacher["TeacherID"] = txtAddIDNumber.Text;
    drNewTeacher["FirstName"] = txtAddFirstName.Text;
    drNewTeacher["LastName"] = txtAddLastName.Text;
    drNewTeacher["E-mail"] = txtAddEmail.Text;
    
    dtTeacher.Rows.Add(drNewTeacher);
    daTeacher.Update(dtTeacher); //Error - Syntax error in INSERT INTO
    Many thanks in advance,

    Steve
    Last edited by steve_rm; Oct 28th, 2004 at 06:00 AM.
    steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width