Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27071

Update OrganisationID

$
0
0
Hi,

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

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

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()

At runtime, I receive the error - Conversion failed when converting the nvarchar value'ABC' to data type int.

Thanks

Viewing all articles
Browse latest Browse all 27071

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>