1 / 15

Changing data in a DB

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

faunus
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.net Inserts, Deletes, and Updates: ‘non-queries’

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

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

  6. 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)

  7. Demo

  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