Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenating 3 fields into one when you insert

Status
Not open for further replies.

ScottNeth

Technical User
Mar 11, 2002
44
US
Ok, clarifying question I had before and hopefully answering Struth's question - I need to concatenate three fields into one (while also entering the three fields seperately) each time a record is added. I know how to run the SQL for this on a SQL server once all the data is there, but how do I drive it into the DB this way?
Cyberpunk Scott Neth
Web Designer/Cyberpunk
 
It would look as if lets say you have three fields
fldArea, fldCity, fldCustID. - Now note I am picking through code that I know works from a gent who made it for me. Might need some tweaking.

Separately you would do like this

strQuery = "INSERT INTO tblScores ([fldArea],[fldCity],[fldCustID]) VALUES (" _
& "'" & Request.Form("fldArea") & "', " _
& "'" & Request.Form("fldCity") & "', " _
& "'" & Request.Form("fldCustID") & "') "
Conn.Execute strQuery

All together would look something like this. - what is in Blue you have to alter.

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strProvider
Conn.BeginTrans


strQuery = "INSERT INTO tblScores ([fldNumber],[fldArea],[fldCity],[fldCustID]) VALUES (" _
& "#" & Request.Form("fldArea") & "-" & Request.Form("fldCity") & "-" & Request.Form("fldCustID") & "#, " _
& "'" & Request.Form("fldArea") & "', " _
& "'" & Request.Form("fldCity") & "', " _
& "'" & Request.Form("fldCustID") & "') "
Conn.Execute strQuery "I like a man who grins when he fights."

-- Prime Minister Winston Churchill

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top