p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 13th, 2005, 12:45 PM
Authorized User
Points: 125, Level: 2
Points: 125, Level: 2 Points: 125, Level: 2 Points: 125, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: , , .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old January 13th, 2005, 02:44 PM
Friend of Wrox
Points: 5,269, Level: 30
Points: 5,269, Level: 30 Points: 5,269, Level: 30 Points: 5,269, Level: 30
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 1 Time in 1 Post
Default

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.]
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
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 12:17 PM
Insert Error FishBoy SQL Server ASP 2 April 7th, 2008 07:45 AM
Syntax error INSERT INTO ITladybug ADO.NET 2 January 31st, 2006 07:50 AM
HELP! Insert Query Error zrm22 Classic ASP Databases 1 January 30th, 2006 06:34 PM
INSERT INTO error TSEROOGY BOOK: Beginning JavaScript 9 December 13th, 2004 09:11 AM



All times are GMT -4. The time now is 04:44 PM.


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