|
|
 |
| Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning VB 6 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.
|
 |

January 13th, 2005, 12:45 PM
|
|
Authorized User
|
|
Join Date: Jan 2005
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
INSERT INTO error
Can someone tell me what is wrong with the code below? I am getting an error but I cannot see it. Thanks.
Imports System.Data
Imports System.Data.OleDb
Public Class frmReceived
Inherits System.Windows.Forms.Form
Public Sub frmReceived_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Public Sub btnAddR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddR.Click
Dim myConnection As OleDbConnection = New _
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=G:\IDC\Received Dispensed Deleted.mdb;User Id=admin;Password=;")
Dim myCommand As OleDbCommand = New OleDbCommand
myCommand.Connection = myConnection
myCommand.CommandText = "INSERT INTO Received" & _
"(Received, Date)" & _
"VALUES (@Received, @Date);"
myCommand.Parameters.Add("@Received", TextBox1.Text)
myCommand.Parameters.Add("@Date", Date.Now)
myConnection.Open()
Try
myCommand.ExecuteNonQuery()
Catch err As OleDbException
MessageBox.Show(err.Message)
Finally
myConnection.Close()
End Try
End Sub
End Class
|

January 13th, 2005, 02:44 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 1 Time in 1 Post
|
|
I believe that your SQL should not have a terminating “;”.
That character is used to signify the end of a line/command/etc., but .CommandText will know where the line ends, and so the ‘;’ is unnecessary. (Anything unnecessary usually causes an error...)
[BTW: This question should probably be in Beginning VB.NET... Just a thought.]
|
| 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
|
|
|
|
 |