SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 combobox values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

EricBHK
Starting Member

18 Posts

Posted - 09/30/2012 :  13:10:18  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 09/30/2012 :  18:40:51  Show Profile  Reply with Quote
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()

Edited by - sunitabeck on 09/30/2012 18:41:29
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000