sammySeltzer
asked on
How to insert firstname + lastname into fullname???
Greetings all,
I have a table called Contacts. This table following:
FirstName,
LastName
Fullname. These are the core of my question.
During an INSERT statement, how do I insert the value of FirstName and Lastname into fieldname called Fullname. THis way, the values look like this:
FirstName LastName Full Name
John Doe John Doe
So, insert statement would look like this:
INSERT INTO Contacts (FirstName, LastName, Fullname) Values (ValueOfFirstName, ValueOfLastName, ValueOfFirstName and LastName combined)
Thanks in advance
I have a table called Contacts. This table following:
FirstName,
LastName
Fullname. These are the core of my question.
During an INSERT statement, how do I insert the value of FirstName and Lastname into fieldname called Fullname. THis way, the values look like this:
FirstName LastName Full Name
John Doe John Doe
So, insert statement would look like this:
INSERT INTO Contacts (FirstName, LastName, Fullname) Values (ValueOfFirstName, ValueOfLastName, ValueOfFirstName and LastName combined)
Thanks in advance
ASKER
Yes, in a sense you are right but here is where I am having issues.
Contact table is a lookup table to another table called Calls.
In other words, Calls table is dependent upon Contacts table for contact name.
So, if we have on Calls table the following:
ContactID,
Call_Date, etc
Now, any time we need to create a new call Record, we would search the Contact Dropdownlist to see if the Caller already exists there. If it does, we pull it and its id is stored on Calls table.
There are times when the wrong Contact name is pulled.
For instance, if We mistakenly pull Contact by the name Joe Blow with ContactID 123, and it turns out that Joe Blow is wrong. It is actually John Doe with contact Id 456, we will now need to update the Calls table.
My question then is how do we update Calls table giving that this is pullded from dropdownlist control and the dropdown is already a computed column?
Your assistance is appreciated and sorry for long, boring explanation.
Contact table is a lookup table to another table called Calls.
In other words, Calls table is dependent upon Contacts table for contact name.
So, if we have on Calls table the following:
ContactID,
Call_Date, etc
Now, any time we need to create a new call Record, we would search the Contact Dropdownlist to see if the Caller already exists there. If it does, we pull it and its id is stored on Calls table.
There are times when the wrong Contact name is pulled.
For instance, if We mistakenly pull Contact by the name Joe Blow with ContactID 123, and it turns out that Joe Blow is wrong. It is actually John Doe with contact Id 456, we will now need to update the Calls table.
My question then is how do we update Calls table giving that this is pullded from dropdownlist control and the dropdown is already a computed column?
Your assistance is appreciated and sorry for long, boring explanation.
INSERT INTO Contacts (FirstName, LastName, Fullname) Values (ValueFirstName, ValueOfLastName, ValueOfFirstName + " " + Value OfLastName)
ASKER
Ok,
I know that but how do I code it in asp.net?
Here is the actual asp.net (vb) code:
"INSERT INTO Contacts (FirstName, LastName, Fullname) " & _
"VALUES (@FirstName,@LastName, @Fullname)", Conn)
cmdcommand.Parameters.AddW ithValue(" @FirstName ", FirstName.Text)
cmdcommand.Parameters.AddW ithValue(" @LastName" , LastName.Text)
cmdcommand.Parameters.AddW ithValue(" @Fullname" , System.Data.SqlDbType.NVar char2)
cmdcommand.Parameters("@Fu llname").V alue = ????
The problem with the above is that I don't want the to have to enter the FullName information.
As soon as the user enters value for firstname, lastname, I want those values inserted into the Fullname fieldname without human involvement.
Any ideas what the real syntax is?
I know that but how do I code it in asp.net?
Here is the actual asp.net (vb) code:
"INSERT INTO Contacts (FirstName, LastName, Fullname) " & _
"VALUES (@FirstName,@LastName, @Fullname)", Conn)
cmdcommand.Parameters.AddW
cmdcommand.Parameters.AddW
cmdcommand.Parameters.AddW
cmdcommand.Parameters("@Fu
The problem with the above is that I don't want the to have to enter the FullName information.
As soon as the user enters value for firstname, lastname, I want those values inserted into the Fullname fieldname without human involvement.
Any ideas what the real syntax is?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I almost figured that one out, not just smart enough.
Thank you!
Thank you!
When you need a full name, you can:
SELECT FirstName, LastName, FirstName+' '+LastName AS FullName FROM Contacts