Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 combobox values

Author  Topic 

EricBHK
Starting Member

18 Posts

Posted - 2012-09-30 : 13:10:18
I have a combobox with items 1 to 31 (for each day of the month). Whenever I want to store the selected item to my Access database, I get an error saying 'values for one or more required parameters are missing'.


Code is below.

I have checked and ComboBox2.Text = definetly value 25.
also the 'Id = & LastRow' part is working fine.

So where am I going wrong ??


If ComboBox2.Text = "25" Then
sql = "UPDATE OwnerChangesArchive SET BornDayNew = " & 25 & " WHERE Id = " & LastRow
cmd = New OleDb.OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
End If

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-30 : 18:40:51
You probably need your sql to be like this:
If ComboBox2.Text = "25" Then
sql = "UPDATE OwnerChangesArchive SET BornDayNew = 25 WHERE Id = " & LastRow
cmd = New OleDb.OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
End If
But, that is rather inflexible. You probably want to make it something like this:
sql = "UPDATE OwnerChangesArchive SET BornDayNew = " & ComboBox2.Text & " WHERE Id = " & LastRow
cmd = New OleDb.OleDbCommand(sql, con)
cmd.ExecuteNonQuery()
Go to Top of Page
   

- Advertisement -