p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB 2008 > BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7
I forgot my password Register Now
Register | FAQ | Members List | Calendar | 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 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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 22nd, 2009, 02:09 PM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old June 22nd, 2009, 04:56 PM
Authorized User
Points: 211, Level: 4
Points: 211, Level: 4 Points: 211, Level: 4 Points: 211, Level: 4
Activity: 13%
Activity: 13% Activity: 13% Activity: 13%
 
Join Date: Jun 2006
Location: Orpington, Kent, United Kingdom.
Posts: 51
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 10th, 2006 12:38 AM
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



All times are GMT -4. The time now is 02:40 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc