I'm taking values from a previous page via request.form and using them to updata a DB.
One of the values is the name of a service but Idon't want to insert that into the table, but rather the primary key (which is a number). In order to do this I need to SELECT the primary key WHERE the service name is equal to the name in the service table.
Problem is once I've done this am not allowed to use this number in my INSERT statement. I get a "type mismatch error". Why?
Here's the code:
<%
username=request.form("user"
servicename=request.form("service"
comment_txt=request.form("commenttxt"
cur_date=Date()
dim SQLstr
SQLstr="SELECT service_no AS testval FROM services WHERE name ='"&servicename&"'"
dim SQLstr1
SQLstr1="INSERT INTO complaints (user_name,service_no,complaint,date_sub) VALUES ('"&username&"','"&testval&"','"&comment_txt&"','"&cur_date&"')"
dim oRS
set oRS = server.createObject("ADODB.Connection"
oRS.open "DSN=power"
oRS.execute SQLstr
oRS.execute SQLstr1
set oRS = nothing
%>
One of the values is the name of a service but Idon't want to insert that into the table, but rather the primary key (which is a number). In order to do this I need to SELECT the primary key WHERE the service name is equal to the name in the service table.
Problem is once I've done this am not allowed to use this number in my INSERT statement. I get a "type mismatch error". Why?
Here's the code:
<%
username=request.form("user"
servicename=request.form("service"
comment_txt=request.form("commenttxt"
cur_date=Date()
dim SQLstr
SQLstr="SELECT service_no AS testval FROM services WHERE name ='"&servicename&"'"
dim SQLstr1
SQLstr1="INSERT INTO complaints (user_name,service_no,complaint,date_sub) VALUES ('"&username&"','"&testval&"','"&comment_txt&"','"&cur_date&"')"
dim oRS
set oRS = server.createObject("ADODB.Connection"
oRS.open "DSN=power"
oRS.execute SQLstr
oRS.execute SQLstr1
set oRS = nothing
%>