150 likes | 215 Views
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.
E N D
Changing datain a DB Stefano Grazioli
Critical Thinking • Schedule shift • No Lab on the 21st • Easy meter
Ado.net Inserts, Deletes, and Updates: ‘non-queries’
ADO.NET architecture Client (your program on your machine) DB Server SqlConnection Connectionstring RemoteDataBase SqlCommand SQL Querystring SqlAdapter DataSetDataTablesDataRows Your objects(e.g. ListObject)
ADO.NET architecture Client (your program on your machine) DB Server SqlConnection RemoteDataBase Connectionstring SqlCommand SQL Querystring Execution Feedback
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)
You do the talking • Name, Major • Learning objectives • Things you like about the class • Things that can be improved • Strengths / Attitude towards the Tournament
Suggestions • Make sure that you understand the ADO architecture diagrams before coding.
WINIT What Is NewIn Technology?
Best Practices Try/Catch
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
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