Hi,
I have a combo box which is populated from a dataset and the query that populates it is;
DisplayMember - OrganisationName
DisplayValue - OrganisationID
Now am trying to have an update statement, whereby it should read the OrganisationID and update that to the database. So the user, clicks from example Google - 1, the value 1 is loaded to the database.
I have this
At runtime, I receive the error - Conversion failed when converting the nvarchar value'ABC' to data type int.
Thanks
I have a combo box which is populated from a dataset and the query that populates it is;
Code:
SELECT OrganisationID, OrganisationName FROM dbo.tblOrganisation
Order By OrganisationName
DisplayValue - OrganisationID
Now am trying to have an update statement, whereby it should read the OrganisationID and update that to the database. So the user, clicks from example Google - 1, the value 1 is loaded to the database.
I have this
Code:
query = "UPDATE dbo.tblCustomer SET OrganisationID=@OrganisationID, CitrixUsername=@CitrixUsername WHERE UserID = @UserID"
cmd = New SqlCommand(query, conn)
cmd.Parameters.AddWithValue("@OrganisationID", IIf(cmbOrgName.ValueMember.Length > 0, cmbOrgName.Text, DBNull.Value))
cmd.Parameters.AddWithValue("@CitrixUsername", IIf(txtusername.Text.Length > 0, txtusername.Text, DBNull.Value))
cmd.Parameters.AddWithValue("@userid", txtuserid.Text)
cmd.ExecuteNonQuery()
Thanks