MS Access Update Statement
Can someone tell me why this segment does not work?
Code:
' CREATE COMMAND AND SET PARAMETERS
invCmd = New OleDbCommand("UPDATE invMain SET Description2=@desc2, Type=@type, " & _
"Inventory=@inv, Trigger=@trig, LeadTime=@lead, Size=@size, Cartridge=@cart " & _
"WHERE (Description1=@part)", invCon)
invCmd.Parameters.Add("@desc2", OleDb.OleDbType.Char)
invCmd.Parameters.Add("@type", OleDb.OleDbType.Char)
invCmd.Parameters.Add("@inv", OleDb.OleDbType.Char)
invCmd.Parameters.Add("@trig", OleDb.OleDbType.Char)
invCmd.Parameters.Add("@lead", OleDb.OleDbType.Char)
invCmd.Parameters.Add("@size", OleDb.OleDbType.Char)
invCmd.Parameters.Add("@cart", OleDb.OleDbType.Char)
invCmd.Parameters.Add("@part", OleDb.OleDbType.Char)
invCmd.Parameters("@desc2").Value = "d2" & Me.uiDescriptionTextBox.Text
invCmd.Parameters("@type").Value = "ty" & Me.uiTypeTextBox.Text
invCmd.Parameters("@inv").Value = Me.uiOnHandTextBox.Text
invCmd.Parameters("@trig").Value = Me.uiTriggerTextBox.Text
invCmd.Parameters("@lead").Value = Me.uiLeadTextBox.Text
invCmd.Parameters("@size").Value = Me.uiSizeTextBox.Text
invCmd.Parameters("@cart").Value = Me.uiCartridgeComboBox.Text
invCmd.Parameters("@part").Value = "d1" & Me.uiPartNumberLabel.Text
It worked fine until I added the second and third items from the bottom. Now I am getting a message that says there is an error in the syntax of my update statement.
Re: MS Access Update Statement
Try .Value instead of .Text for the Combobox line. Just an idea.
Re: MS Access Update Statement
A combobox does not have a .Value property.
Re: MS Access Update Statement
Assign the value of the combo box to a variable and then the parameter check the value of the variable in debug mode. If it's OK then the added part
of your update syntax is incorrect. I had similar trouble using @name with access and had to change it to ? in the Update syntax.
Fishy
Re: MS Access Update Statement
Quote:
Originally Posted by circuits2
A combobox does not have a .Value property.
It does in Access 2000. Don't know about other versions.
Re: MS Access Update Statement
I should have clarified. I am developing a VB.NET application that interfaces with an Access Database.
Re: MS Access Update Statement
You don't need brackets around your where clause so that might be causing it but I'd have expected Access to allow it.
What values are in your various combo and text boxes? It's possible one of them contains an illegal character.