notes on ado from other projects please use speaker notes for additional information!

Post on 13-Dec-2015

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Notes on ADO from other projects

Please use speaker notes for additional information!

UpdateUpdate

Private Sub cmdAdd_Click() ADODonor.Recordset.AddNewEnd Sub

Private Sub cmdDelete_Click() ADODonor.Recordset.Delete ADODonor.Recordset.MoveFirstEnd Sub

Private Sub cmdMoveFirst_Click() ADODonor.Recordset.MoveFirstEnd Sub

Private Sub cmdMoveLast_Click() ADODonor.Recordset.MoveLastEnd Sub

Private Sub cmdMoveNext_Click() ADODonor.Recordset.MoveNextEnd Sub

Private Sub cmdMovePrevious_Click() ADODonor.Recordset.MovePreviousEnd Sub

Private Sub cmdUpdate_Click() ADODonor.Recordset.UpdateEnd Sub

CodeCode

Private Sub Form_Load()Dim strConnectStr As String

databasepath = App.PathIf Right(databasepath, 1) <> "\" Then databasepath = databasepath & "\"End Ifdatabasepath = databasepath & "donor.mdb"strConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="strConnectStr = strConnectStr & databasepathADODonor.ConnectionString = strConnectStr'ADODonor.CommandType = adCmdText'ADODonor.RecordSource = "SELECT * from Donor2000 ORDER BY DIdno"ADODonor.CommandType = adCmdTableADODonor.RecordSource = "Donor2000"ADODonor.RefreshADODonor.Recordset.Sort = "DIdno"End Sub

CodeCode

Another approach.

Making this form portable.

PrDonorinGrid.vbpPrDonorinGrid.vbp

PrDonorinGrid.vbpPrDonorinGrid.vbpConnection string is done in Form_Load to make the program portable.

The caption code puts a caption over the specified columns. The visible code eliminates two columns. In this program we do not see street address or zip. Note also the width code which sets the width of two columns.

PrDonorinGrid.vbpPrDonorinGrid.vbp

The column information specified in the code on the previous slide is implemented.

PrADOACDstuy.vbpPrADOACDstuy.vbp

The beginning steps to add a new record.

PrADOACDstuy.vbpPrADOACDstuy.vbp

In form load, the connection string and record source are established. The recordset is also sorted by idno (the key field).

Here I add a new record with AddNew, populate it with data and then Update the field that I added.

PrSQL4ADOy.vbpPrSQL4ADOy.vbp

PrSQL4ADOy.vbpPrSQL4ADOy.vbp

PrSQL5ADOy.vbpPrSQL5ADOy.vbp

PrSQL5ADOy.vbpPrSQL5ADOy.vbp

PrSQL6ADOy.vbpPrSQL6ADOy.vbp

PrSQL6ADOy.vbpPrSQL6ADOy.vbp

PrSQL6ADOy.vbpPrSQL6ADOy.vbp

PrSQL6ADOy.vbpPrSQL6ADOy.vbp

Bookmark or hold the current location.

When no match is found the holdBookmark is used.

top related