|
|
 |
BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7
 | This is the forum to discuss the Wrox book Beginning Microsoft Visual Basic 2008 by Thearon Willis, Bryan Newsome; ISBN: 9780470191347 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

June 22nd, 2009, 02:09 PM
|
|
Registered User
|
|
Join Date: Aug 2008
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Connecting,edit,update & Deleting records from database programatically.
Hi,
Can anybody tell me how to connect a database,edit,update & delete records from database (on forms) programatically ? Please give complete example.
|

June 22nd, 2009, 04:56 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Location: Orpington, Kent, United Kingdom.
Posts: 51
Thanks: 1
Thanked 1 Time in 1 Post
|
|
This may help ...
PublicClass frmUpdate
PrivateConst CONNECT_STRING AsString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Databases\bm2009.mdb; Persist Security Info=False"
----------------------------------------------------------------------------------------------
PrivateSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click
' open the connection.
Dim conn_times24 AsNew OleDb.OleDbConnection(CONNECT_STRING)
conn_times24.Open()
' make a command to insert the data
Dim cmd AsNew OleDb.OleDbCommand("INSERT INTO 24hrTimes (Time_Number) VALUES (?)", conn_times24)
Dim x As Byte
x=1
' add the number 1 to Time_Number field
cmd.Parameters.Add(New OleDb.OleDbParameter("Time_Number", x))
' execute the command.
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
EndTry
conn_times24.Close()
conn_times24.Dispose()
lblOP.Text = " Done ! "
EndSub
-------------------------------------------------------------------------------------------------------------
EndClass
In this I've opened a database using a connectioin string ( obviously substitute in your code, the appropriate file path & D.B. name.) Then inserted a value of 1 into the named field ' Time_Number'. You will need to check the syntax for deletion, and updating, but this is the format that V.B. 2008, expects the S.Q.L. to be in programmatically.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |