0

the error i get while executing the code below in OleDb

        Try
            con.Open()
            Dim cmd As New OleDbCommand("Select * from customer", con)
            cmd.CommandText = " update customer set hr =@hr,min =@min "
            cmd.Parameters.AddWithValue("@hr", ComboBoxHr.SelectedIndex.ToString())
            cmd.Parameters.AddWithValue("@min", ComboBoxMin.SelectedIndex.ToString())
            cmd.ExecuteNonQuery()
            TwoDigit(ComboBoxHr)
            MessageBox.Show("CONRATULATIONS! ...Click the Start button to see the changes")
        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString())
        End Try

Which works fine if i remove the "min" part. What could be the reason?

0

2 Answers 2

2

I believe AakashM is right. You can however use a keyword as a column name as long as you put it in [] like

Try
        con.Open()
        Dim cmd As New OleDbCommand("Select * from customer", con)
        cmd.CommandText = " update customer set hr =@hr,[min] =@min "
        cmd.Parameters.AddWithValue("@hr", ComboBoxHr.SelectedIndex.ToString())
        cmd.Parameters.AddWithValue("@min", ComboBoxMin.SelectedIndex.ToString())
        cmd.ExecuteNonQuery()
        TwoDigit(ComboBoxHr)
        MessageBox.Show("CONRATULATIONS! ...Click the Start button to see the changes")
    Catch ex As Exception
        MessageBox.Show(ex.Message.ToString())
    End Try
Sign up to request clarification or add additional context in comments.

1 Comment

You folks are awesome. PROBLEM SOLVED thanks for saving my a** again :D
2

MIN is a keyword in SQL (it's the aggregate function for finding the minimum of a group of values). Either use a different name for your column, or enclose it in [ square brackets ] - I'm not actually sure if this will work in Access, mind...

1 Comment

You folks are awesome. PROBLEM SOLVED thanks for saving my a** again :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.