daniness
Well-known member
- Joined
- Feb 12, 2010
- Messages
- 49
- Programming Experience
- Beginner
Hello All,
I'm back! Hoping you can help me with this one.
I have an app I'm working on with multiple forms. One of the forms, frmLocationInfo, has textboxes and comboboxes which are automatically populated based on a combobox selection from a previous form, frmLocations. I've been able to get any changes made to frmLocationInfo's textboxes to save to the SQL database, however, when attempting to select a different item from any of its comboboxes, it's not saving to the database and instead, I receive a "Procedure or function...has too many arguments specified" error.
Here is the code for the Save button:
I was told that every time a different item is selected from a combobox, the value should be reassigned to the variable and this should happen in the "SelectedIndexChanged" event, so this is what I tried:
As always, your assistance is appreciated.
I'm back! Hoping you can help me with this one.
I have an app I'm working on with multiple forms. One of the forms, frmLocationInfo, has textboxes and comboboxes which are automatically populated based on a combobox selection from a previous form, frmLocations. I've been able to get any changes made to frmLocationInfo's textboxes to save to the SQL database, however, when attempting to select a different item from any of its comboboxes, it's not saving to the database and instead, I receive a "Procedure or function...has too many arguments specified" error.
Here is the code for the Save button:
VB.NET:
'Save changes to Locations db
Private Sub btnSaveClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveClose.Click
'Passing value from controls to variables
clsMain.Location_str_value = txtLoc.Text
'clsMain.Location_refnbr = frmLocations.cboLocations.SelectedValue
clsMain.Location_refnbr = lblSiteRefNbr.Text
clsMain.AAC_str_value = txtAAC.Text
clsMain.Phone_str_value = txtPhone.Text
clsMain.Fax_str_value = txtFax.Text
clsMain.Email_str_value = txtEmail.Text
clsMain.Depot_str_value = cboDepot.Text
clsMain.Depot_refnbr = cboDepot.ValueMember
clsMain.FrghtFrwrdr_str_value = cboFreight.Text
clsMain.Frght_refNbr = cboFreight.SelectedValue
clsMain.Dsptchr_str_value = cboDispatcher.Text
clsMain.Dsptchr_refNbr = cboDispatcher.SelectedValue
If Not conn.State = ConnectionState.Open Then conn.Open()
'Create command object, open stored procedure, and pass connection string
Dim myCommand As SqlCommand = New SqlCommand("dbo.sp_OrderTracking_Update_UpdateItem", conn)
myCommand.CommandType = Data.CommandType.StoredProcedure
myCommand.Parameters.AddWithValue("@site", clsMain.Location_str_value)
myCommand.Parameters.AddWithValue("@siteRefnbr", clsMain.Location_refnbr)
myCommand.Parameters.AddWithValue("@aac", clsMain.AAC_str_value)
myCommand.Parameters.AddWithValue("@phoneNbr", clsMain.Phone_str_value)
myCommand.Parameters.AddWithValue("@faxNbr", clsMain.Fax_str_value)
myCommand.Parameters.AddWithValue("@Email", clsMain.Email_str_value)
myCommand.Parameters.AddWithValue("@depot", clsMain.Depot_str_value)
myCommand.Parameters.AddWithValue("@depotRefnbr", clsMain.Depot_refnbr)
myCommand.Parameters.AddWithValue("@freight", clsMain.FrghtFrwrdr_str_value)
myCommand.Parameters.AddWithValue("@freightRefnbr", clsMain.Frght_refNbr)
myCommand.Parameters.AddWithValue("@dsptchr", clsMain.Dsptchr_str_value)
myCommand.Parameters.AddWithValue("@dispatchRefnbr", clsMain.Dsptchr_refNbr)
myCommand.ExecuteNonQuery().ToString()
MessageBox.Show("Location successfully saved.", "Changes Saved", MessageBoxButtons.OK)
End Sub
I was told that every time a different item is selected from a combobox, the value should be reassigned to the variable and this should happen in the "SelectedIndexChanged" event, so this is what I tried:
VB.NET:
Private Sub cboDepot_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDepot.SelectedIndexChanged
clsMain.Depot_str_value = cboDepot.Text
clsMain.Depot_refnbr = cboDepot.ValueMember
End Sub
As always, your assistance is appreciated.