p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 (http://p2p.wrox.com/forumdisplay.php?f=384)
-   -   Command Objects ( S.Q.L. in sub-routine ) ? (http://p2p.wrox.com/showthread.php?t=75015)

liamfitz June 29th, 2009 03:46 PM

Command Objects ( S.Q.L. in sub-routine ) ?
 
[:confused:]I'm trying to 'refresh' an existing dataset and DataGridView, using the following code, in a click-event routine. I'm sure I've got some of the objects/methods wrong. Can anyone assist ? ( Pages 424-427 ?)
Code:


PrivateSub btnSBig_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles btnSBig.Click
' open the connection.
Dim conn_initialcust AsNew OleDb.OleDbConnection(CONNECT_STRING)
conn_initialcust.Open()
' make a command to select the data
Dim cmd AsNew OleDb.OleDbCommand("SELECT Forename, [Middle Initial], Surname FROM Customers WHERE Surname LIKE 'S*';", conn_initialcust)
' execute the command.
Try
cmd.ExecuteReader()
Catch ex As Exception
MessageBox.Show(ex.Message)
EndTry
conn_initialcust.Close()
conn_initialcust.Dispose()
EndSub


I'm sure the problem's from the ' Dim cmd ' line onwards. Thanks.


All times are GMT -4. The time now is 07:09 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.