But I would recommend getting rid of all the stuff I commented out and the stuff I commented for. They had no use whatsoever... like the "s = executescalar" part and the errorsstr and errorstr1 part. Unless you still plan on implementing them!

thanks it work but i can not add more than 1 product do i have to put loop

yes. You would first have to put your products into an array and then do a "for each item in arrname ....... next"

If you need help, I am available for the next hour and 20 minutes or so.

wait, ONLY if you are allowing them to check checkboxes to add many products at a time, like a batch add. If they have to click each product to add to the cart, then no because they can only add one product at a time.

they will add by entring product number in the text box the error appear when i try to add another on is in the attachment as screen shot and how can i make the order no increase automatically

Yes you have to do a for each loop. All the code is there, just surround it like this:

for ....
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()
next

what about the problem in adding did you see the msg??

Now because you have more than 1 textbox on the page, you will have to add a fake attribute to each textbox you want this to hit. To do this, since all your textboxes are asp.net controls anyway, just in page_load type this for each one:
textboxname1.Attributes.Add("product","product")
textboxname2.Attributes.Add("product","product")

or you can create an onItemCreated event and assign it to only those controls where it adds
this.attributes.add("product","product")

for you, I think the first solution would be simpler. Then you can just use the bottom code and it will do it for you.

Dim Ctrl As Control
for each Ctrl in Page.Controls
  if TypeOf Ctrl Is TextBox and Ctrl.Attributes("product") = "product" then
    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()
  end if
next

the code will be in the insert sub ?

thanks a lot you are the best

actually, I don't that would work for you.. on second thoughts, why don't you create a repeater that will produce all the product fields that you need. This way each itemtemplate will keep it all separate for you and you can use this code below:

Dim rc AS RepeaterItemCollection = rpName.Items
    For Each Item As RepeaterItem In rc
        Dim product As TextBox = CType(Item.FindControl("product"), TextBox)
        Dim Quantity As TextBox = CType(Item.FindControl("Quantity"), TextBox)
        If product.length > 0 and Quantity.length > 0 and Quantity.Text > 0 Then
            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()
        End if			
    Next

And you have no such thing called pri, that's what I think you had "s" declared for? :)

and for how many times the repeater should go, you can create a public variable... let's say ipub and let it equal to zero. then everytime it is used, increment it by one.. like this:

Dim ipub As Integer = 0

Function NumberProducts()
ipub += 1
return (ipub)
End Function

You can have this number the rows for you as well, if you don't want it to, remove return (ipub)

thanks I submit project and discuss it

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.