The Tip of the ADO-burg Francisco H Tapia. Ado Objects Command Connection Error Parameter Property...

Post on 27-Dec-2015

213 views 0 download

Transcript of The Tip of the ADO-burg Francisco H Tapia. Ado Objects Command Connection Error Parameter Property...

The Tip of the ADO-burg

Francisco H Tapia

Ado Objects

Command Connection Error Parameter

Property Record RecordSet Stream

Who’s your provider?

Connection providers…

OLEdb providers– JET– SQL– TEXT– XML– mySQL– Etc…

What’s in a command?

Excute stored procedures or queries where a result is not expected back

– .Execute , , adExecuteNoRecords

Pass multiple parameters– .Parameters.Append .CreateParameter("CompanyName", _ adVarWChar,

adParamInput, 50, sCompanyName)– .Parameters.Append .CreateParameter("ContactFirstName", _ adVarWChar,

adParamInput, 30, sContactFirstName)– .Parameters.Append .CreateParameter("ContactLastName", _ adVarWChar,

adParamInput, 50, sContactLastName)

Receive a return a single pice of data instead of a recordset…–     .Parameters.Append .CreateParameter("RETURN_VALUE", _ adInteger,

adParamReturnValue, 0) –     ' Print new identity value     Debug.Print .Parameters("job_id").Value  ' New

Identity

http://www.able-consulting.com/ADO_Faq.htm

Recordsets…

Conn.stp_MyStoredProcedure Param1, rs– Store Access queries in MDB BE– Create an updateable recordset on the fly

OR Use the Command object to execute the

procedure.– Set rs = cmd.execute

Dispelling myths…

ADO is Faster! Not necessarily, while DAO is optimized for JET, ADO is optimized to take advantage of a whole slew of languages. In reality if you are planning to process thousands of JET records in code, you should look at DAO instead of ADO. SQL for example is using an optimized OLEdb provider vs the ODBC provider, thus ADO is the current supported data access model.

ADO requires less code The object model is is flatter thus requiring less coding…

MS Access 97 cannot use ADO code

False. ADO can be added as a reference in code, and executed the same way in Access 97 as you can in Access 2000/2002. Intellisense is not aware of the ADO library though.

LINKS!!!

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmscadoprogrammersguide.asp

http://www.able-consulting.com/ADO_Faq.htm http://www.devguru.com/technologies/ado/quickref/ado_index.html http://www.vbsquare.com/databases/begado/\ www.google.com