VBCE.com - The Premier Website For Visual Basic/CE Developers

 

*Dev Corner

Sample Code
Controls
Workarounds
Tips & Tricks
Q & A
Forums

*Goodies
Downloads
Software
Bookstore


*General
Home
What's New
General Info
Misc. Info


*News Worthy
News
Articles
Editorials
KB Articles
Reviews
Awards

*Miscellaneous
Web Links
Partners
Search
Feedback
Advertising

Sponsors


More...



ADOCE SQL - Select | Update | Insert | Delete

The SQL command consists of the following commands and conditions:

  • select

    The select command returns information in a single table according to the rules you specify. The columns in a table are called fields, and the rows are called records. In ADO, the table returned by the select statement is called a recordset. The select statement generates this recordset from existing tables according to the parameters that follow it.

  • from

    The * from addresses command notifies the database engine to return all the fields in the addresses table. The asterisk (*) wildcard character means “all fields.” The fields specified here become the columns in the new recordset.

  • where

    The where lastname = ‘Smith’ condition restricts the rows returned to only the ones containing the string “Smith” in the lastname field. The rows specified here become the rows in the new recordset. If there are no Smiths in the addresses table, the recordset is empty.

  • order by

    The order by lastname, firstname command notifies the database engine to sort the records before returning them. The engine sorts the records first by last name, then by first name.

 

'-- ADOCE Recordset
Dim rs

Select
rs.Open "SELECT * FROM tblName"

 

Update - Unfortunately there is not an UPDATE SQL statement, so therefore you must query the database, find the specific record, and perform the update.

rs.Open "SELECT name FROM tblName where name = 'Scott'"
rs("Name") = "ScottL"
rs.Update

 

Delete
rs.Open "DELETE FROM tblName WHERE name = 'scott'"

 

Insert
rs.Open "INSERT into tblName (a, b, c) VALUES (101, 102, 103)"

 

VBCE.com is DevX Winner!

Unless otherwise noted, all information on VBCE.com is Copyright 1998 - 2002
Windows, Windows CE, and Visual Basic are trademarks of the Microsoft Corporation.
VBCE.com is not responsible for content on external sites.
Send all feedback to webmaster@vbce.com
Webmasters - feel free to link to
VBCE.com - Premier Website for Visual Basic/CE Development

Buy Books!