Forums

This topic is locked

Joining 2 textbox and insert into 1 DBfield

Posted 14 Jul 2003 07:06:13
1
has voted
14 Jul 2003 07:06:13 NaiWah Lui posted:
hi

I am wondering is there anyway that i could join 2 textbox and insert into 1 DB column field. For example, i have one txtfields which hold an ID:ABC and another txtField holds a value:1234. When i click on the insert button the DB field should read as ABC1234.

Thanks

Replies

Replied 14 Jul 2003 13:24:10
14 Jul 2003 13:24:10 Lee Diggins replied:
Hi

What web server and what db are you using?

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 16 Jul 2003 15:55:53
16 Jul 2003 15:55:53 NaiWah Lui replied:
hi

I am using IIS and SQL2000 as my DB.

Thanks

Replied 16 Jul 2003 16:48:27
16 Jul 2003 16:48:27 Lee Diggins replied:
Hi

I've done this with two pages.

Form Page:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="myFormPost.asp">
<input type="text" name="textfield">
<input type="text" name="textfield2">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>

myFormPost.asp Page:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim strData
strData = Request.Form("textfield" & Request.Form("textfield2"
Dim strSQL
strSQL = "INSERT INTO myTable (myColumn) VALUES ('" & strData & "')"

Dim strConn
Dim objConnection

Set objConnection = Server.CreateObject("ADODB.Connection"
strConn = "INSERT YOUR CONNECTION STRING HERE!!!!!!!"

objConnection.Open strConn
objConnection.Execute strSQL

objConnection.Close

%>

You need to make the neccessary changes to the strSQL variable to match your database and the strConn to match your connection string.

Digga

Sharing Knowledge Saves Valuable Time!!!

Reply to this topic