use my version and let me know what is wrong. The only reason why there should be an error in your FROM clause is if the table order does not exist.

I am using microsoft visual 2005
I uused your code and here is a shot screen

gosh I am really not paying attention today. THat's not a valid Delete statement that's why. Change your delete code to this:

"DELETE FROM order WHERE Product_Number=?"

it deletes everything automatically, that's why you don't supply what to delete.

here is the complete project including database
still the same error after changhing Delete

at work I can't view this, or whatever, but when I get home i'll try it

here is the project forgot to attach it

ok thanks when are you going home
is it ok to contact you by email I suppose to submit the project tommorow

please answer me

thank u

i made some changes, please check your PM's at the top of the page (click on PM) and check it.

thank you but still the same errors

well I don't have MSAccess on this machine at work and I don't have VS either. So, all the code is correct and the only place that there can be flaws are in either the Connection String or the Access Database. I cannot look at the database, and I don't believe there is a problem there. So try connecting to your database.

Create a dummy page that has your attempt to connect.

Try
con.Open()
response.write("connected successfully")
Catch ex as OleDbException
response.write("failed to connect<br /><br />Reason is:<br />" & ex)
Finally
con.Close()
End Try

oh and my bad, access keeps the "*" for delete command, so change that back:

DELETE * FROM....

Try
con.Open()
response.write("connected successfully")
Catch ex as OleDbException
response.write("failed to connect<br /><br />Reason is:<br />" & ex)
Finally
con.Close()
End Try

Where I put this at which SUB

when I put it an error appear here is a screen shot of it

create either a new page and place it in a sub page_load or replace your entire sub page_load on that page as it was uneeded anyway. Test it like that and let me know.

The ConnectionString property has not been initialized.

this error appear

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim con As OleDbConnection

        con = New OleDbConnection

     
        Try
            con.Open()
            Response.Write("connected successfully")
        Catch ex As OleDbException
            Response.Write("failed to connect<br /><br />Reason is:<br />")
        Finally
            con.Close()
        End Try


    End Sub

this is my sub page_load

and this is the error

The ConnectionString property has not been initialized.

there is a screen shot of it

you have to specify the con. here use this exact code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Documents and Settings\USER\Desktop\my\WebSite4\App_Data\EC.mdb';Persist Security Info=True")

        Try
            con.Open()
            Response.Write("connected successfully")
        Catch ex As OleDbException
            Response.Write("failed to connect<br /><br />Reason is:<br />" & ex)
        Finally
            con.Close()
        End Try

    End Sub

don't forget to add the ex. just "Toggle Plain Text" and copy and paste.

connected successfully but still the insert , remove doesn't work the same msg appear

& ex
when I put it it appear as error

Error 3 Operator '&' is not defined for types 'String' and 'System.Data.OleDb.OleDbException'. C:\Documents and Settings\USER\Desktop\my\WebSite4\cart.aspx.vb 26 28 C:\...\WebSite4\

hmm, okay. All that matters is that you connected successfully.

Now what error appears for when you click getproduct for the INSERT, and what error do you get for the DELETE?

INSERT

Syntax error in INSERT INTO statment

DELETE

Syntax error in FROM clause

Try replacing your sub remove_click with this one below. Let me know what it says.

Protected Sub remove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles remove.Click
        Dim u As String = Session("user")
        cmd = New OleDbCommand("DELETE * FROM [order] WHERE ([Product_Number] = ?)", con)
        cmd.Parameters.AddWithValue("?Product_Number", Trim(productNum.Text))

        Try
            If con.State = Data.ConnectionState.Closed Then
                con.Open()
	    End if

            Dim recs As Integer = cmd.ExecuteNonQuery()

            ''If this next if statement poses an error for you, remove it and just put a successful statement.
            If recs > 0 Then
                'successfully updated a record
                Response.Write("Product successfully removed.....")
            Else
                'failed to update record
                Response.Write("We're sorry, there was an error processing your request. Please try again.")
            End If
        Catch ex As OleDbException
            MsgBox(ex.Message)
        End Try
    End Sub

    Protected Sub check_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles check.Click
        MsgBox("Thank you for ordering we hope you visit us again")
    End Sub

it works please try with the add

thanks a lot

the only thing I did extra is adding the [] to all the columns. This just means that there was a case problem within your column names or table name. table name "order" is not the same as "Order" but with the [] it is both the same. [order] is the same as [Order]. Here's the fix for the entire page sir.:

Imports System.Data.OleDb
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls.TextBox

Partial Class cart
    Inherits System.Web.UI.Page
    Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Documents and Settings\USER\Desktop\my\WebSite2\App_Data\EC.mdb';Persist Security Info=True")
    Dim cmd As OleDbCommand

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Dim con As OleDbConnection
        '
        'con = New OleDbConnection
        '
        'con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Documents and Settings\USER\Desktop\my\WebSite4\App_Data\EC.mdb';Persist Security Info=True"
        'If con.State = Data.ConnectionState.Closed Then
        '    con.Open()
        'End If
        '
        'This whole section is not needed, at all!
    End Sub


    Protected Sub getproduct_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles getproduct.Click
        If Session("user") = Nothing Then
            Response.Redirect("login.aspx")
        Else
            Dim x As String = Session("user")
            Dim LongTimeString As String = ""
            Dim DateToString As String = ""
            Dim ShortTimeString As String = ""
            Dim LongDateString As String = ""
            Dim Daysinmonth As Integer = 0
            Dim ErrorStr As String = ""
            Dim ErrorStr1 As String = ""

            Dim OrderDate = System.DateTime.Now
            LongTimeString = OrderDate.ToLongTimeString
            Daysinmonth = System.DateTime.DaysInMonth(OrderDate.Year, OrderDate.Month)
            DateToString = OrderDate.ToString
            ShortTimeString = OrderDate.ToShortTimeString
            LongDateString = OrderDate.ToLongDateString
    
            '' Start - Determine use for these next two if statements.
            If (product.Text = "") Then
            ErrorStr = ErrorStr & " Please Enter Product number, "
            End If

            If (Quantity.Text = "") Then
                ErrorStr1 = ErrorStr1 & " Please Enter Product quantity, "
            End If
            '' End

            Try
                If con.State = Data.ConnectionState.Closed Then
                    con.Open()
                End If

                ''Start - Determine use for 's'
                cmd = New OleDbCommand("SELECT [price] FROM [product] WHERE ([ProductNO] = ?)", con)
                cmd.Parameters.AddWithValue("?ProductNO", Trim(product.Text))

                Dim s As String = cmd.ExecuteScalar()
                ''End

                cmd = New OleDbCommand("INSERT INTO [order] ([OrderNo], [quantity], [price], [date], [member_UserName], [Product_Number]) Values (?, ?, ?, ?, ?, ?)", con)
                cmd.Parameters.AddWithValue("?OrderNo", 2)
                cmd.Parameters.AddWithValue("?quantity", Trim(Quantity.Text))
                cmd.Parameters.AddWithValue("?price", pri)
                cmd.Parameters.AddWithValue("?date", Daysinmonth)
                cmd.Parameters.AddWithValue("?member_UserName", x)
                cmd.Parameters.AddWithValue("?Product_Number", Trim(product.Text))

                cmd.ExecuteNonQuery()

                If Not con.State = Data.ConnectionState.Closed Then
                    con.Close()
                End If
            Catch ex As OleDbException
                MsgBox(ex.Message)
            End Try
      
        End If
    End Sub


    Protected Sub remove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles remove.Click
        Dim u As String = Session("user")
        cmd = New OleDbCommand("DELETE * FROM [order] WHERE ([Product_Number] = ?)", con)
        cmd.Parameters.AddWithValue("?Product_Number", Trim(productNum.Text))

        Try
            If con.State = Data.ConnectionState.Closed Then
                con.Open()
	    End if

            Dim recs As Integer = cmd.ExecuteNonQuery()

            ''If this next if statement poses an error for you, remove it and just put a successful statement.
            If recs > 0 Then
                'successfully updated a record
                Response.Write("Product successfully removed.....")
            Else
                'failed to update record
                Response.Write("We're sorry, there was an error processing your request. Please try again.")
            End If
        Catch ex As OleDbException
            MsgBox(ex.Message)
        End Try
    End Sub

    Protected Sub check_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles check.Click
        MsgBox("Thank you for ordering we hope you visit us again")
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.