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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP & Forms

Status
Not open for further replies.

damann

Technical User
Jul 19, 2000
114
US
I need to get all the values from a form (the values the user inputs) then put those values into a database. Can anyone show me examples of this using vbscript?


Thank you
 

dim var1
dim var2

var1 = request.form("ID of element in form")

objRS("DB field name") = var1
objRS.update

*of course you need to have an active DB connection and the appropiate locktype set.

Hope this helps.
 
I get an error when I implement our code. Here it is below:

Microsoft OLE DB Provider for ODBC Drivers error '80040e0c'

Command text was not set for the command object.

/intern/Admincontacts.asp, line 18


This is my code, can you tell me what Im doing wrong...


<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/dbconn.asp&quot; -->

<%
set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.ActiveConnection = MM_dbconn_STRING

dim grp, title, cname, loc, phone, fax, pgr

grp = request.form(&quot;group&quot;)
title = request.form(&quot;title&quot;)
cname = request.form(&quot;name&quot;)
loc = request.form(&quot;location&quot;)
phone = request.form(&quot;phone&quot;)
fax = request.form(&quot;fax&quot;)
pgr = request.form(&quot;pager&quot;)

objRS(&quot;group&quot;) = grp
objRS(&quot;title&quot;) = title
objRS(&quot;name&quot;) = cname
objRS(&quot;location&quot;) = loc
objRS(&quot;phone&quot;) = phone
objRS(&quot;fax&quot;) = fax
objRS(&quot;pager&quot;) = pgr
objRS.update
%>

<html>
<head>
<title>Add A Contact</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<form name=&quot;addContacts&quot; method=&quot;POST&quot; action=&quot;admincontacts.asp&quot;>
<table width=&quot;50%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;20%&quot;>Group</td>
<td width=&quot;80%&quot;>
<input type=&quot;text&quot; name=&quot;group&quot;>
</td>
</tr>
<tr>
<td width=&quot;20%&quot;>Title</td>
<td width=&quot;80%&quot;>
<input type=&quot;text&quot; name=&quot;title&quot;>
</td>
</tr>
<tr>
<td width=&quot;20%&quot;>Name</td>
<td width=&quot;80%&quot;>
<input type=&quot;text&quot; name=&quot;name&quot;>
</td>
</tr>
<tr>
<td width=&quot;20%&quot;>Location</td>
<td width=&quot;80%&quot;>
<input type=&quot;text&quot; name=&quot;location&quot;>
</td>
</tr>
<tr>
<td width=&quot;20%&quot;>Phone</td>
<td width=&quot;80%&quot;>
<input type=&quot;text&quot; name=&quot;phone&quot;>
</td>
</tr>
<tr>
<td width=&quot;20%&quot;>Fax</td>
<td width=&quot;80%&quot;>
<input type=&quot;text&quot; name=&quot;fax&quot;>
</td>
</tr>
<tr>
<td width=&quot;20%&quot;>Pager</td>
<td width=&quot;80%&quot;>
<input type=&quot;text&quot; name=&quot;pager&quot;>
</td>
</tr>
</table>

</form>
</body>
</html>
 
you forgot to open the rs

<%
set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.ActiveConnection = MM_dbconn_STRING
objRS.Open
dim grp, title, cname, loc, phone, fax, pgr

grp = request.form(&quot;group&quot;)
title = request.form(&quot;title&quot;)
cname = request.form(&quot;name&quot;)
loc = request.form(&quot;location&quot;)
phone = request.form(&quot;phone&quot;)
fax = request.form(&quot;fax&quot;)
pgr = request.form(&quot;pager&quot;)

'are you adding a record? if so you need this line, and to have the right cursor
objRS.AddNew
objRS(&quot;group&quot;) = grp
objRS(&quot;title&quot;) = title
objRS(&quot;name&quot;) = cname
objRS(&quot;location&quot;) = loc
objRS(&quot;phone&quot;) = phone
objRS(&quot;fax&quot;) = fax
objRS(&quot;pager&quot;) = pgr
objRS.update
%>
leo
 
ok, here's my new code. I still get this error stating:

Microsoft OLE DB Provider for ODBC Drivers error '80040e0c'

Command text was not set for the command object.

/intern/Admincontacts.asp, line 8


Check out the code, I think I got everything done correctly... Please let me know...

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<%
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.ActiveConnection = MM_dbconn_STRING
objRS.CursorType = 0
objRS.Open
objRS.CursorLocation = 2
objRS.LockType = 3

dim grp, title, cname, loc, phone, fax, pgr

grp = request.form(&quot;group&quot;)
title = request.form(&quot;title&quot;)
cname = request.form(&quot;name&quot;)
loc = request.form(&quot;location&quot;)
phone = request.form(&quot;phone&quot;)
fax = request.form(&quot;fax&quot;)
pgr = request.form(&quot;pager&quot;)

objRS.AddNew
objRS(&quot;group&quot;) = grp
objRS(&quot;title&quot;) = title
objRS(&quot;name&quot;) = cname
objRS(&quot;location&quot;) = loc
objRS(&quot;phone&quot;) = phone
objRS(&quot;fax&quot;) = fax
objRS(&quot;pager&quot;) = pgr
objRS.update
%>

 
Please do refer to FAQ atleast once, before posting a question. Thank you...
RR

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top