Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Structured Query Language SQL. SQL Select Command SELECT * FROM tableName WHERE criteria;

Similar presentations


Presentation on theme: "Introduction to Structured Query Language SQL. SQL Select Command SELECT * FROM tableName WHERE criteria;"— Presentation transcript:

1 Introduction to Structured Query Language SQL

2 SQL Select Command SELECT * FROM tableName WHERE criteria;

3 Creating A String Containing SQL Select Command Assuming the rating is selected from a list box: dim strSQL as string = "select * from customer where rating = ‘” strSQL = strSQL & ListBox1.SelectedItem & "‘”

4 SQL Insert Command INSERT INTO tableName VALUES (field values separated by commas); Ex 1. Customer table with CID, CNAME, CITY, RATING. INSERT INTO CUSTOMER VALUES (‘C1’, ‘SMITH’, ‘SF’, ‘A’); Ex 2. Orders table with OID, OrderDate, CID, SalesPerson INSERT INTO ORDERS VALUES (‘O11’, #9/28/02#, ‘C1’, ‘Peter’);

5 Creating A String Containing SQL Insert Command Assuming the four fields of the new customer record are entered in textboxes: Dim strSQLInsert As String strSQLInsert = "Insert into Customer values ('" strSQLInsert = strSQLInsert & TextBox1.Text & "','" & TextBox2.Text & "','" strSQLInsert = strSQLInsert & TextBox3.Text & "','" & TextBox4.Text & "')"

6 SQL Delete Command DELETE FROM tableName WHERE criteria; Ex 1. Delete a record from the Customer table. DELETE FROM CUSTOMER WHERE CID = ‘C1’;

7 Creating A String Containing SQL Delete Command Assuming the deleted record’s ID is selected from a list box: Dim strSQLDel As String = “DELETE FROM CUSTOMER WHERE CID = ‘“ strSQLDel = strSQLDel & ListBox1.SelectedItem & "'"

8 SQL Update Command UPDATE tableName SET field = new value WHERE criteria; Ex. UPDATE CUSTOMER SET RATING = ‘A’ WHERE CID=‘C1’;

9 Creating A String Containing SQL Update Command Assuming the CID is selected from a list box, and the new rating is entered in a text box: Dim strSQLUpd As String = "Update customer set rating = '" & textbox1.text & "'" strSQLUpd = strSQLUpd & " where cid='" & ListBox1.SelectedItem & "'"


Download ppt "Introduction to Structured Query Language SQL. SQL Select Command SELECT * FROM tableName WHERE criteria;"

Similar presentations


Ads by Google