Forums
This topic is locked
Insert 2 form fields into 1 DB field
Posted 22 Aug 2002 15:36:43
1
has voted
22 Aug 2002 15:36:43 Mitchel Tendler posted:
Hi,Is it possible to insert 2 form fields into 1 Access DB field?
Example:
Form field firstname = John
Form field lastname = Doe
Name field in Database = John, Doe
Thanks!
Mitch
Replies
Replied 23 Aug 2002 09:15:57
23 Aug 2002 09:15:57 Vince Baker replied:
Yes,
You will need to process the update on a second page....
Send the form to a page titled for example Employee_Insert_script.asp
and send the form values from the first page using the get method.
On the second page have the following code:
<!--#include file="YOUR_CONN_FOLDER_PATH/YOUR_CONN_NAME" -->
<% Dim strfirstname, strsurname, strFullname, sql, InsertRecords
strfirstname = Request.querystring("firstname"
strsurname = Request.querystring ("surname"
strFullname = strfirstname & ", " & strSurname
sql = "Insert into YOURTABLENAME (Name) VALUES ('" & strFullname & "')"
%>
<%
set InsertRecords = Server.CreateObject("ADODB.Command"
InsertRecords.ActiveConnection = MM_YOUR_CONNECTION_NAME_STRING
InsertRecords.CommandText = sql
InsertRecords.CommandType = 1
InsertRecords.CommandTimeout = 0
InsertRecords.Prepared = true
InsertRecords.Execute()
%>
You may need to add some extra form fields into the sql line for the other fields in your form.
good luck,
<% Response.write(The best line of code you can ever use"
%>
Vince
VBScript | ASP | HTML | SQL | Oracle | Hosting
Edited by - bakerv on 23 Aug 2002 09:22:37
You will need to process the update on a second page....
Send the form to a page titled for example Employee_Insert_script.asp
and send the form values from the first page using the get method.
On the second page have the following code:
<!--#include file="YOUR_CONN_FOLDER_PATH/YOUR_CONN_NAME" -->
<% Dim strfirstname, strsurname, strFullname, sql, InsertRecords
strfirstname = Request.querystring("firstname"

strsurname = Request.querystring ("surname"

strFullname = strfirstname & ", " & strSurname
sql = "Insert into YOURTABLENAME (Name) VALUES ('" & strFullname & "')"
%>
<%
set InsertRecords = Server.CreateObject("ADODB.Command"

InsertRecords.ActiveConnection = MM_YOUR_CONNECTION_NAME_STRING
InsertRecords.CommandText = sql
InsertRecords.CommandType = 1
InsertRecords.CommandTimeout = 0
InsertRecords.Prepared = true
InsertRecords.Execute()
%>
You may need to add some extra form fields into the sql line for the other fields in your form.
good luck,
<% Response.write(The best line of code you can ever use"

Vince
VBScript | ASP | HTML | SQL | Oracle | Hosting
Edited by - bakerv on 23 Aug 2002 09:22:37
Replied 24 Aug 2002 16:37:23
24 Aug 2002 16:37:23 Mitchel Tendler replied:
Thanks bakerv!
Mitch
Mitch