View Single Post
  #1 (permalink)  
Old January 13th, 2005, 12:45 PM
akibaMaila akibaMaila is offline
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
Reply With Quote