My computer-based training piece sends user data to asp pages which relay the
data on to a SQLServer 2000 database. All works well with one exception:
when a new record is created, any spaces in the string containing the user's
name are deleted.
When the training piece sends the variable User_Name="John Doe" to the asp
page, it issues an SQL INSERT command. The result: the SQLServer table that
receives the data displays the name JohnDoe. What might cause the space to
be deleted?
The asp page contains this code:
<%@ Language=VBScript %>
<%
Option Explicit
Response.expires = 0
dim conn, SQL, strConn, strSite, strUserName, strUserID, ProcApproach,
Rqmts1, Rqmts2, Rqmts3, Rqmts4, Rqmts5
dim CorT1, CorT2, CorT3, CorT4, CorT5, Audit1, Audit2, Audit3, Audit4,
Audit5, RoleMgrs1, RoleMgrs2, RoleMgrs3, RoleMgrs4, RoleMgrs5
dim RoleMgrs6, RoleMgrs7, RoleMgrs8, ScoreTotal, ModComplIntro,
QComplProcApproach, QComplRqmts, QComplCorT, QComplAudit, QComplRoleMgrs
'Get data from AW. IIS examples recommend the HTMLEncode
'method of the ASP Server object but the method doesn't work w/ AW.
'Use Request.Form method.
strSite=Request.Form("Site")
strUserName=Request.Form("User_Name")
strUserID=Request.Form("User_ID")
ProcApproach=Request.Form("Proc_Approach")
Rqmts1=Request.Form("Rqmts_1")
Rqmts2=Request.Form("Rqmts_2")
Rqmts3=Request.Form("Rqmts_3")
Rqmts4=Request.Form("Rqmts_4")
Rqmts5=Request.Form("Rqmts_5")
CorT1=Request.Form("CorT_1")
CorT2=Request.Form("CorT_2")
CorT3=Request.Form("CorT_3")
CorT4=Request.Form("CorT_4")
CorT5=Request.Form("CorT_5")
Audit1=Request.Form("Audit_1")
Audit2=Request.Form("Audit_2")
Audit3=Request.Form("Audit_3")
Audit4=Request.Form("Audit_4")
Audit5=Request.Form("Audit_5")
RoleMgrs1=Request.Form("RoleMgrs_1")
RoleMgrs2=Request.Form("RoleMgrs_2")
RoleMgrs3=Request.Form("RoleMgrs_3")
RoleMgrs4=Request.Form("RoleMgrs_4")
RoleMgrs5=Request.Form("RoleMgrs_5")
RoleMgrs6=Request.Form("RoleMgrs_6")
RoleMgrs7=Request.Form("RoleMgrs_7")
RoleMgrs8=Request.Form("RoleMgrs_8")
ScoreTotal=Request.Form("Score_Total")
ModComplIntro=Request.Form("Mod_Compl_Intro")
QComplProcApproach=Request.Form("Q_Compl_ProcApproach")
QComplRqmts=Request.Form("Q_Compl_Rqmts")
QComplCorT=Request.Form("Q_Compl_CorT")
QComplAudit=Request.Form("Q_Compl_Audit")
QComplRoleMgrs=Request.Form("Q_Compl_RoleMgrs")
'Build SQL INSERT command.
SQL="INSERT INTO User_Data_TS VALUES ('" & strSite & "','" & strUserName &
"','" & strUserID & "',"
SQL=SQL & ProcApproach & "," & Rqmts1 & "," & Rqmts2 & "," & Rqmts3 & "," &
Rqmts4 & "," & Rqmts5 & ","
SQL=SQL & CorT1 & "," & CorT2 & "," & CorT3 & "," & CorT4 & "," & CorT5 & ","
SQL=SQL & Audit1 & "," & Audit2 & "," & Audit3 & "," & Audit4 & "," & Audit5
& ","
SQL=SQL & RoleMgrs1 & "," & RoleMgrs2 & "," & RoleMgrs3 & "," & RoleMgrs4 &
"," & RoleMgrs5 & "," & RoleMgrs6 & "," & RoleMgrs7 & "," & RoleMgrs8 & "," &
ScoreTotal & ","
SQL=SQL & "'" & ModComplIntro & "','" & QComplProcApproach & "','" &
QComplRqmts & "','" & QComplCorT & "','" & QComplAudit & "','" &
QComplRoleMgrs & "');"
'Create a connection object which opens a connection to the server
'Establish a link to the SQL Server database with strConn
'Use the Execute method to send the SQL query to database
'Close recordset and db connection as early as possible
strConn="Provider=sqloledb; Data Source=BUSPC\QS; Initial Catalog=ISO_TS;
User ID=sa; Password=xxxxx"
set conn=Server.CreateObject("ADODB.Connection")
conn.open strConn
conn.Execute(SQL)
conn.close
set conn = nothing
%>
The SQLServer table uses the character data type for the User_Name variable.
Thanks.