1 Replies - 291 Views - Last Post: 30 September 2011 - 03:59 AM Rate Topic: -----

#1 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

problem with my sql statement

Posted 30 September 2011 - 03:50 AM

Hi all i am having a problem with my update sql statement when i add an extra value i get the error No given value for one or more parameters. If i take out the last value i add which is (actionedBy) it works but when i add it i get the error can't see what i have done wrong

My code: Update sub

    Sub UpdateCustomer(ByVal HNCNO As Integer, ByVal Forename As String, ByVal Surname As String, ByVal DOB As String, ByVal actionedBY As String)

        OpenDatabaseConnction()
        Dim cm As New OleDb.OleDbCommand(" Update Details Set HNCNO = '" & HNCNO & "',Forename= '" & Forename & "',Surname= '" & Surname & "',DOB='" & DOB & "',ationedBY='" & actionedBY & "' WHERE HNCNO = " & HNCNO, DBCon)
                MessageBox.Show(cm.CommandText.ToString())
        Try
            cm.ExecuteScalar()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            CloseDatabaseConnction()
        End Try
    End Sub



the save button

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim customerDS As DataSet
        Dim ans As Integer

        customerDS = dataAccess.ShowSpecficCustomer(frmShowAllDetails.HNCNO)
        If txtDOB.Text <> customerDS.Tables("Details").Rows(0).Item(3).ToString() Then

            ans = MessageBox.Show("DOB is not the same. Do you still want to save", "", MessageBoxButtons.YesNo)
            If ans = Windows.Forms.DialogResult.No Then
                Exit Sub ' if the user clicks the no option on the message box then exit this sub and don't save
            End If
        End If
        dataAccess.UpdateCustomer(frmShowAllDetails.HNCNO, txtForename.Text, txtSurname.Text, txtDOB.Text, txtActionedBy.Text)

        MsgBox("Customer updates saved", MsgBoxStyle.Information)

        Dim ds As DataSet
        ds = dataAccess.ShowALLCustomerAccountDetails()

        Me.Close()
        frmShowAllDetails.Show()
    End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: problem with my sql statement

#2 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: problem with my sql statement

Posted 30 September 2011 - 03:59 AM

it's ok i figured it out it was the name of the colums of my database :withstupid:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1