SQL Coding
August 10, 2011 12:00 AM
Can someone check my syntax in the following snippet please:
<%@ Language=VBScript %>
<%
'Get the student ID from the program'
studentID=Request.form("_StudentID")
'declare the SQL statement that will query the database
sql = "SELECT ti_first_name FROM Trainee_Information WHERE ti_SSN = '" & studentID & "'"
'create an instance of the ADO connection and recordset objects
Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
'open the connection to the database
conn.Open "vsc_ttc2000"
'Open the recordset object executing the SQL statement and return records
rs.Open sql,conn
' Assign the parameters posted on the login page'
response.Write(rs.fields("ti_first_name").value)
'close the connection and recordset objects to free up resources
rs.Close
Set rs=nothing
conn.Close
Set conn=nothing
%>
I can't seem to get any data out of the database. The names of the variables and database are spelled correctly, and the db is a system DSN.
Thanks!
Discussion (1)
Hello. I am trying to do the same. and I need little bit help of u. I need to write a C#.NET script so that I can fetch my values from lectora to my SQL server database. Even if in vbscript, it would be ok. Can you help me out|?
Discussions have been disabled for this post