Click to See Complete Forum and Search --> : MS Access INSERT Trouble


Banksy
07-24-2005, 09:34 PM
This is the code for my connection to the database...

<%
Dim connection, query, data

'Instanciate the ADO connection object
Set connection = Server.CreateObject( "ADODB.Connection" )
Call connection.Open( "dsnCaps" )
%>

This is the code for my HTML...

<html>
<body>
<form name="PlayerForm" method="post" action="player_actions/add_user.asp" onsubmit="return formCheck(this);">
<TABLE cellspacing="0" cellpadding="0" border="0" width = "450">
<!-- FIRST NAME -->
<TR>
<td><span class="bodytext">
First Name:</TD>
<TD>
<input type="text" name="FirstName" size="50" maxlength="50" class="flatbox">
</span></td>
</TR>
<!-- LAST NAME -->
<TR>
<td><span class="bodytext">
Last Name: </TD>
<TD>
<input type="text" name="LastName" size="50" maxlength="50" class="flatbox">
</span></td>
</TR>
</TABLE>
</form>
</body>
</html>

This is the code for my insertion to the database...

<%
sFirstName = Request("FirstName")
sLastName = Request("LastName")

%>

<!-- OPEN DATABASE CONNECTION -->
<!--#include file="connect.asp"-->
<%

'DEFINE VARIABLES AND RECORD DETAILS TO DATABASE
Dim sSQL

' Define the SQL query
sSQL = "INSERT INTO tblUser (FirstName, LastName) VALUES ('"&sFirstName&"','"&sLastName&"')"
Set connection.Execute(sSQL)
'---------------------------------------------------------------------
%>
<html>
<body>
<form name="PlayerForm" method="post" action="player_actions/add_user.asp" onsubmit="return formCheck(this);">
<TABLE cellspacing="0" cellpadding="0" border="0" width = "450">
<!-- FIRST NAME -->
<TR>
<td><span class="bodytext">
First Name:</TD>
<TD>
<input type="text" name="FirstName" size="50" maxlength="50" class="flatbox">
</span></td>
</TR>
<!-- LAST NAME -->
<TR>
<td><span class="bodytext">
Last Name: </TD>
<TD>
<input type="text" name="LastName" size="50" maxlength="50" class="flatbox">
</span></td>
</TR>
</TABLE>
</form>
</body>
</html>

There is obviously something wrong with this line of code

Set connection.Execute(sSQL)

but I am not sure what else I am supposed to use...Anyone have any suggestions?
Thanks In Advance!!!

buntine
07-25-2005, 03:21 AM
Remove "Set ". Just call the function.

Regards.