Paul_98 0 Newbie Poster

Can someone help me with this as I am having problems. My problem is that after i click button 2 for placing the order the data from the checkout form should go to the database but it does not work, there is no sign of that. I don't know if the problem is from the "me.cmdd = Insert", I just put the the "me" there because if i remove that there will be errors, the errors that shows is "local variable 'cmdd' cannot be referred to before its declared" The langues i use is vb.net.

(Source Code)
Imports finalproj.productdetails
Imports System.Data.OleDb

Public Class checkout1

Dim pros As String
Dim cntion As String
Dim cmdd As String
Dim myconnection As OleDbConnection = New OleDbConnection


Private Sub checkout_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    date1.Text = DateTime.Now.ToLongDateString

    item.Text = product_name
    qty.Text = product_qty
    price.Text = product_price
    total.Text = (product_price * product_qty)


End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    cart.Show()
    Me.Hide()

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    item.Text = ""
    qty.Text = ""
    total.Text = ""
    price.Text = ""

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

    pros = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source = C:\Users\saballo0805\Desktop\Lalalala\Programs\finalproj\finalproj\bin\Debug\Team 12 12 02 - CPG, Database.accdb"
    cntion = pros
    myconnection.connectionstring = cntion
    myconnection.Open()

    Me.cmdd = "Insert INTO Customer Info VALUES ([Customer Name], [Contact No], [Age], [Address], [Item Name], [Price], [Quantity], [Total]) values ('" & name12.Text & "','" & cont.Text & "','" & age.Text & "','" & address.Text & "','" & item.Text & "','" & price.Text & "','" & qty.Text & "','" & total.Text & "')"
    Dim cmdd As OleDbCommand = New OleDbCommand(Command, myconnection)
    cmdd.Parameters.Add(New OleDbParameter("Customer Name", CType(name12.Text, String)))
    cmdd.Parameters.Add(New OleDbParameter("Contact No", CType(cont.Text, String)))
    cmdd.Parameters.Add(New OleDbParameter("Age", CType(age.Text, String)))
    cmdd.Parameters.Add(New OleDbParameter("Address", CType(address.Text, String)))
    cmdd.Parameters.Add(New OleDbParameter("Item Name", CType(item.Text, String)))
    cmdd.Parameters.Add(New OleDbParameter("Price", CType(price.Text, String)))
    cmdd.Parameters.Add(New OleDbParameter("Quantity", CType(qty.Text, String)))
    cmdd.Parameters.Add(New OleDbParameter("Total", CType(total.Text, String)))
    MsgBox("Your Item Is Preparing For Shipment")

    Dim answer As String

    answer = MsgBox("Do you want to buy again?", vbQuestion + vbYesNo + vbDefaultButton2)

    If answer = vbYes Then
        cart.Show()

    Else
        End
    End If


    Try
        cmdd.ExecuteNonQuery()
        cmdd.Dispose()
        myconnection.Close()
        name12.Clear()
        cont.Clear()
        age.Clear()
        address.Clear()
        item.clear()
        qty.Clear()
        total.Clear()
        price.Clear()
        total.Clear()


    Catch ex As Exception

    End Try



End Sub

End Class