• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Bonus card points problem with code vb 2005

I have this code  in order formprovide  by an expert(Thnks so much) the use of this code is when  a customer buy something from the store and have a bonus card  to  update the points of his her bonuscard.

I try it and is ok but i get error

dbcmd.CommandText = "Update Bonuses Set Points = Points+ " & Totalorder & " Where CardNo = " & BonusCardTextBox1.Text

What is Update bonuses is a table is somthing else please some one help

My points is pointstextbox.text my bonuscarnumber=BonusCardTextBox1.Text and the Totalorder is  TotalorderTextbox.text
Private Sub OrdersDetailsBindingSourceBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrdersBindingNavigatorSaveItem.Click
        If BonusCardTextBox1.Text.Length > 0 Then
            Dim Totalorder As Integer = Integer.Parse(TotalorderTextBox.Text)
            Dim dbcon As New OleDb.OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data " & "Source = D: NicolaouDb.mdb ; User Id = ; " & _
"Password = ")
            Dim dbcmd As New OleDb.OleDbCommand
            dbcmd.Connection = dbcon
            dbcmd.CommandText = "Update Bonuses Set PointsTextBox = PointsTextBox + " & Totalorder & " Where CardNo = " & BonusCardTextBox1.Text
            MessageBox.Show("You could have earned " & Integer.Parse(TotalorderTextBox.Text) & " points with this order if you had a bonus card.")
        End If
    End Sub

Open in new window

  • 5
  • 3
1 Solution
What is the error message?

You might want to set the CommandType to text like this:

dbcmd.CommandType = CommandType.Text

Open in new window

Also is the field in your DB called PointsTextBox or Points? You have PointsTextBox in your SQL

dbcmd.CommandText = "Update Bonuses Set PointsTextBox = PointsTextBox + " & Totalorder & " Where CardNo = " & BonusCardTextBox1.Text

should this be:

dbcmd.CommandText = "Update Bonuses Set Points = Points + " & Totalorder & " Where CardNo = " & BonusCardTextBox1.Text

demoniumzAuthor Commented:
Data type mismatch in criteria expression

"Update Bonuses Set Points

What is Bonuses is a table is something else i dont understand it
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

demoniumzAuthor Commented:
also  now i see that totalorder that is exist  in the database have no value inside the ms access database 2003
Update Bonuses Set Points = Points + " & Totalorder & " Where CardNo = " & BonusCardTextBox1.Text

Bonuses should be a table in your database for this sql to work.
It should have at least 2 fields - Points and CardNo, from this is looks like CardNo is the primary key.

TotalOrder is an integer value that is retrieved in the above code from the TotalorderTextBox control which I assume is on your form.
demoniumzAuthor Commented:
Listen me i have then  table Customers inside of this table i have The Points and Bonuscard

Now i am  in the Orderdetails form that save and take data from the Total order is in integer but when  i  save the data i have in the datagridview and give me the result,the result is not saved in the orderdetails table

how i can  save the Totalorder in the database?
demoniumzAuthor Commented:
No value given for one or more required parameters. .The field that have not value is Totalorder i  am not able to save it in the database the result can u  explain me help me save this
demoniumzAuthor Commented:
original solution provided by jpaulino in a similar question  but helping me  GuitarRich so is fair to  accepted  as solution
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now