Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8
This is the forum to discuss the Wrox book Visual Basic 2008 Programmer's Reference by Rod Stephens; ISBN: 9780470182628
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 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
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 22nd, 2009, 03:44 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
Unhappy Inserting D.B. records programatically ( entering the same value in all records ? )

When I run the following code, it enters the number 1 in every record in the specified field. It should enter the nos. 1 to 144, as I'm sure you can see. Any suggestioins ? ( I've traced the execution step by step, and the value of x increases in increments of 1 as it should ) Please help.[code]
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)
' add the numbers 1 to 144 to Time_Number field
Dim x AsByte
For x = 1 To 144
cmd.Parameters.Add(
New OleDb.OleDbParameter("Time_Number", x))
' execute the command.
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
EndTry
Next x
conn_times24.Close()
conn_times24.Dispose()
lblOP.Text =
" Done ! "
EndSub

the rest works fine ! just the 'for' loop in question.
 


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting,edit,update & Deleting records from database programatically. sheelnathkekre BOOK: Beginning Microsoft Visual Basic 2008 ISBN: 978-0-470-19134-7 1 June 22nd, 2009 03:56 PM
Inserting Returned Records hugh@kmcnetwork.com SQL Language 2 November 4th, 2003 01:05 PM
Inserting records into a databae aadz5 ASP.NET 1.0 and 1.1 Basics 1 October 19th, 2003 10:47 AM



All times are GMT -4. The time now is 12:00 AM.


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