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

sending values to database

Status
Not open for further replies.

aos

MIS
Feb 28, 2002
20
US
<%@ language = vbscript%>
<%option explicit%>

<html>

<head>
<%
Dim First
Dim Second
Dim EmailAddr
Dim dbCon

Set dbCon = Server.CreateObject(&quot;ADODB.Connection&quot;)

dbCon.Open(&quot;DSN=BISDATA; UID=98038320; PWD=handball&quot;)




Sub Details()

First= Request.Form(&quot;FName&quot;)
Second = Request.Form(&quot;LName&quot;)
EmailAddr = Request.Form(&quot;Email&quot;)


Hi i'm trying to send these values into an oracle db. But i'm running into errors. Any ideas?
Thanks!

Dim sqlStatement
sqlStatement = &quot;INSERT INTO CONTACTS
VALUES('&quot;&(Second)&&quot;','&quot;&(First)&&quot;','&quot;&(EmailAddr)&&quot;');&quot;

dbCon.Execute(sqlStatement)

End Sub



Details()
%>
 
One error you might receive is with your SQL statement. If the order of your attribute is wrong it could give you an error (though not in this case since they are all strings). In the future you may want to try something like:
sqlStatement = &quot;INSERT INTO CONTACTS(SecondFieldName,FirstFieldName,EmailAddrFieldName)
VALUES('&quot;&(Second)&&quot;','&quot;&(First)&&quot;','&quot;&(EmailAddr)&&quot;');&quot;

Where the ______fieldname is replaced by the field in the db you are trying to populate.

2nd possible problem: If any of your values come through your form as Null, it will cause your variable to be null, which will attempt to insert a null value into your table. If the table is not set up to accept null values than nothing gets inserted (and you get no error)

There are several more possibilities also. Here is what I generally try in the situation.

1) Print out my sql string after I create it.
2) Copy and Paste it into the db program and see if it executes
3) If it executes fine than the problem is with your asp or your connection object
4) If it doesn't execute than you get a helpful error message and it is probably your SQL

If you could be more verbose concerning the error I may know specifically whats wrong.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top