# SQL statements in ASP/VBscript don't execute



## lbarrack (Apr 9, 2007)

I am writing a timepunch addition to an existing timecard web app tied to a SQL 7 backend. I have isolated enough of the problem down to what I think is trying to submit the statements without using the classic form/response schema. Here is a very dumbed down version of what I'm doing since I think the problem may be on a basic structural level (I hope).

vbscript,session variables and SQL connection and recordset stuff here

'sample of sql insert statement (not the real thing)
set sqlTimeIn = Server.CreateObject ("ADODB.Command")
sqlTimeIn.ActiveConnection = MM_timecardasp_STRING
sqlTimeIn.CommandText = "INSERT INTO dbo.tbltimepunchcard (SSN) VALUES ( ) " 
sqlTimeIn.CommandType = 1
sqlTimeIn.CommandTimeout = 0
sqlTimeIn.Prepared = true

testpin = request.form("punchcard.onclick") 'button gets pushed

case TimeIn
sqlTimeIn.Execute() 
case LunchOut
some sql update statement
case LunchIn
some sql update statement
case TimeOut
some sql update statement
End select

HTML stuff including body
some table data displayed from a recordset
<%
If punchtype <> "TimeIn" Then 'button value logic
If vLunchOut="" then 'default value is "TimeIn"
punchtype = "LunchOut" 'for no record
response.write "punchout"& punchtype
ElseIf vLunchIn="" and punchtype <> "TimeIn" then
punchtype = "LunchIn"
response.write "punchout"& punchtype
ElseIf vTimeOut="" and punchtype <> "TimeIn" then
punchtype = "TimeOut"
response.write "punchout"& punchtype
End If
End If
%>

'this is the button that's suppose to trigger the SQL 
/>

Nothing happens. I'm sure it's some kind of client side vs. server side error on my part. Please help.


----------



## Rockn (Jul 29, 2001)

It isn't doing anything because the app doesn't know what to run? The form generally fires off the action as far as what needs to be done. From what I see here there is nothing client side to process anything. 

Is there a reason you don't want to use the form action?


----------



## lbarrack (Apr 9, 2007)

I'm not sure how I would construct this. Would it go like this:

<form name = "theForm2" id="theForm2" method = "Post" onsubmit = "call timepunch_OnClick" Action = ?"

/>

I'm not really sure how to try this.


----------



## Rockn (Jul 29, 2001)

The action = would be whatever page you want to process your form entries.


----------

