View Single Post
  #1 (permalink)  
Old June 22nd, 2009, 03:44 PM
liamfitz liamfitz is offline
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]
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)
' 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
New OleDb.OleDbParameter("Time_Number", x))
' execute the command.
Catch ex As Exception
Next x
lblOP.Text =
" Done ! "

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