1 / 15

Changing Data in a DB

Changing Data in a DB. Stefano Grazioli. Critical Thinking. Schedule shift No Lab on the 21st Easy meter. ADO. Inserts, Deletes, and Updates: ‘non-queries’. ADO Architecture. Client (your program on your machine). DB Server. SqlConnection. Connection string. Remote DataBase.

cynara
Download Presentation

Changing Data in a DB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Changing Datain a DB Stefano Grazioli

  2. Critical Thinking • Schedule shift • No Lab on the 21st • Easy meter

  3. ADO Inserts, Deletes, and Updates: ‘non-queries’

  4. ADO Architecture Client (your program on your machine) DB Server SqlConnection Connectionstring RemoteDataBase SqlCommand SQL Querystring SqlAdapter DataSetDataTablesDataRows Your objects(e.g. ListObject)

  5. ADO architecture Client (your program on your machine) DB Server SqlConnection RemoteDataBase Connectionstring SqlCommand SQL Querystring Execution Feedback

  6. Demo

  7. String.Format -- insert into Customer2 (C_id, F_name, L_name, City, State) -- values ('C0992','Max', 'Plank', 'Roanoke', 'VA') newCId = Range("K2").ValuenewFName= Range("K3").ValuenewLName= Range("K4").ValuenewCity= Range("K5").ValuenewState= Range("K6").ValuesqlStringAsString = String.Format("insert into Customer2 (C_id, F_name, L_name, City, State) values ('{0}','{1}','{2}','{3}','{4}')", newCId, newFName, newLName, newCity, newState)

  8. You do the talking • Name, Major • Learning objectives • Things you like about the class • Things that can be improved • Strengths / Attitude towards the Tournament

  9. Homework

  10. Suggestions • Make sure that you understand the ADO architecture diagrams before coding.

  11. WINIT What Is NewIn Technology?

  12. Best Practices Try/Catch

  13. Try myConnection.Open() ‘… there might be more statements Catch MessageBox.Show("Ouch! I have justcrashed. “,MessageBoxButtons.OK, MessageBoxIcon.Exclamation) EndTry Example try-catch This will be tried This will run only if something goes wrong while trying

  14. A Mixed Blessing • While developing an algorithm, crashes are often very informative • Bad idea to use try/catches as part of an algorithm • Put the try/catches in as a last step, after testing

More Related