tailieunhanh - Using Visual Basic NET Databases to Create Pricing Trading R_6

Tham khảo tài liệu 'using visual basic net databases to create pricing trading r_6', tài chính - ngân hàng, tài chính doanh nghiệp phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Structured Query Language 233 The UNION Keyword A UNION is useful if you want to get data from two tables within the same result set. For example if we want to see the bid and ask for INTC as well as the bids and asks for all the INTC options in one result set the SQL statement would read as follows Select StockSymbol Bid Ask FROM Stock WHERE StockSymbol IBM UNION Select OptionSymbol Bid Ask FROM Optioncontracts WHERE StockSymbol IBM See Figure . The data type for the columns in each SELECT statement must match for a UNION to work. This is not an issue in the above example because each of the tables has identical column sets. The INSERT Statement Up to this point we have only queried the database and looked at the results. We may however also be interested in changing the data. In order to add delete or modify the data in the FIGURE Team-LRN 234 Database Programming database we will first need to add some elements to our SQLexample program. Step 5 Add another button to your form. Step 6 Add the following code to the Button2_Click event Private Sub Button2_Click ByVal sender As . Handles Try Dim command As New OleDbCommand myConnect Catch MsgBox Please enter a valid SQL statement. Finally End Try End Sub An OleDbCommand object is an SQL statement that we can use to perform transactions against a database. We use the ExecuteNonQuery member method to execute UPDATE INSERT and DELETE statements. For the remainder of the chapter SELECT statements should be executed using the first button and all other transactions should be executed using this new second button. The SQL INSERT statement enables us to add data to a table in a database. Here is an example showing the syntax for adding a record to the OptionTrades table INSERT INTO OptionTrades TradeDateTime OptionSymbol BuySell Price Quantity TradeStatus VALUES 02 27 2003 IBMDP B 10 F You can verify .

TỪ KHÓA LIÊN QUAN