I have done coding in Classic ASP for selecting the two options through drop down and Submitting the selected value to update database. It is not working. I am using SQL Query in "../sqlConnection.asp" location which basically contains the query to update Database Value for Year and Season. I checked the database sql query in SQL server, SQL code works to update Year and Season. But just updating through Classic ASP is not working. Below is my code in Classic ASP:
Suggested Solution that worked:
I used action attribute in form tag. I had to do this in sql query asp file, here in my case ../sqlConnection.asp: PCE_Update.Open(sqlqry) and I had to include another asp file where connection strings were defined which I was missing.
Working Code - Edited Code following suggestions:
../Example.asp:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Option Explicit %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Project Site</title>
<link rel="stylesheet" href="../css/reports.css" type="text/css" />
<style type="text/css">
</style>
</head>
<!--#include file="../sqlConnection.asp" -->
<!--#include file="../sqlConnection1.asp" -->
<%
Dim YearID
Dim SeasonID
Dim myStudentID
YearID = Request.Form("dYear")
SeasonID = Request.Form("dSeason")
If Request.ServerVariables("REQUEST_METHOD")= "POST" Then
myID = Request.QueryString("uniqueid")
Updatedate myID, YearID, SeasonID
End If
%>
<body>
<div align = "center">
<div>
<form id="form1" method="post" action="Example.asp<%= request.querystring %>">
<select class="dropYear" name="dYear">
<option value="select">2014</option>
<option value="2015">2015</option>
</select>
   
<select class="dropSeason" name="dSeason">
<option value="select">FALL</option>
<option value="Winter">WINTER</option>
</select>
<br /><br />
<ul class="buttons">
<input id="save" method="post" class="btTxt" type="submit" value="Submit"; />
</ul>
</form>
</div>
<br/>
</div>
</body>
</html>
Here is my SQL query in "../sqlConnection.asp" which is being called from above code. This below SQL query works perfectly when I run in SQL Server, It updates year and season for particular employee id accordingly.
../sqlConnection.asp
Dim employeeid
Dim futureyear
Dim futureseason
Dim sqlquery
Dim PCE_Update
Dim sisconn
Sub Updatedate (employeeid,futureyear,futureseason)
sqlquery="update userdefinedind " & _
"set ayear = '" & futureyear & "' , aseason = '" & futureseason & "' " & _
"where employee_id = '" & employeeID & "' "
Response.Write(sqlquery)
set PCE_Update = server.CreateObject("ADODB.Recordset")
with PCE_Update
.ActiveConnection = sisconn
.CursorType = 1
.CursorLocation = 2
.Source = sqlqry
end with
PCE_Update.Open(sqlqry)
end sub
Is there anything I am missing? Please suggest. I don't work much in Classic ASP and thought I might be missing simple step here.