Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7
| Search | Today's Posts | Mark Forums Read
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 22nd, 2009, 01:09 PM
Registered User
 
Join Date: Aug 2008
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
  #2 (permalink)  
Old June 22nd, 2009, 03:56 PM
Authorized User
Points: 312, Level: 6
Points: 312, Level: 6 Points: 312, Level: 6 Points: 312, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2006
Location: Orpington, Kent, United Kingdom.
Posts: 73
Thanks: 1
Thanked 1 Time in 1 Post
Lightbulb 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"
----------------------------------------------------------------------------------------------
Private
Sub 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.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add/Update/Delete Database records MANUALLY jn148 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 December 14th, 2008 10:18 AM
Deleting all the records in a table suthaharmca Beginning VB 6 4 January 2nd, 2008 06:14 PM
update records in the database by checkbox Sakina Classic ASP Basics 2 September 9th, 2006 11:38 PM
database connecting with java &mysql rakeshkumar MySQL 1 February 4th, 2005 11:59 AM
how to edit/ update records/ rows of csv file vb thePervertedMonk VB How-To 1 December 10th, 2004 02:15 PM





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