UPDATE a DropDownList box~ HElp Please

  • Thread starter Thread starter Brad Isaacs
  • Start date Start date
B

Brad Isaacs

Using ASP.NET 2.0 with SQL Server 2000

Inside my dropdown list box I am using an SQL DataSource

SELECT RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS Contact,
c.phone As PriPortPhone
FROM mppaContacts c

Now I am trying to UPDATE the table name mppaContacts with what the user
selects from the drop down list box.

How do I UPDATE the table when the names are concatenated? I need to
select a substring for the Name_First field then for the Name_Last field.



UPDATE mppaContacts
SET
[Name_First] = @FirstName
[Name_last] = @LastName
[phone] = @phone


Any ideas would be greatly appreciated........not sure how to extract the
individual names and place them into their specific fields.


Thanks in advance

~Brad
 
Using ASP.NET 2.0 with SQL Server 2000

Inside my dropdown list box I am using an SQL DataSource

SELECT RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS Contact,
c.phone As PriPortPhone
FROM mppaContacts c

Now I am trying to UPDATE the table name mppaContacts with what the user
selects from the drop down list box.

How do I UPDATE the table when the names are concatenated? I need to
select a substring for the Name_First field then for the Name_Last field.

UPDATE mppaContacts
SET
[Name_First] = @FirstName
[Name_last] = @LastName
[phone] = @phone

Any ideas would be greatly appreciated........not sure how to extract the
individual names and place them into their specific fields.

Thanks in advance

~Brad


Have you tried this?

UPDATE mppaContacts
SET
[Name_First] = @FirstName
[Name_last] = @LastName
[phone] = @phone
WHERE rtrim([Name_First]) + ' ' + rtrim([Name_last]) =
rtrim(@FirstName) + ' ' + rtrim(@LastName)

It's not going to be terribly efficient but since you aren't using an
obvious key value to retrieve the data and you could update multiple
rows if the first name/last name combination isn't a key.

I would recommend returning a ContactID in your original query and
using that as your ValueMember on the combo box instead of the First
Name/Last Name combination(?).

Austin
 
Back
Top