What kind of database are you using? and did you actually make the DSN?
Jared
Jared
<%
Dim oConn, oRs
Dim qry, connectstr
Dim db_path
Dim db_dir
db_dir = Server.MapPath("access_db") & "\"
db_path = db_dir & "yourdatabasefile.mdb"
fieldname = "your_field"
tablename = "your_table"
connectstr = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & db_path
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM " & tablename
Set oRS = oConn.Execute(qry)
if not oRS.EOF then
while not oRS.EOF
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
"
oRS.movenext
wend
oRS.close
end if
Set oRs = nothing
Set oConn = nothing
%>
<%
Dim oConn, oRs
Dim qry, connectstr
Dim db_path
Dim db_dir
db_dir = Server.MapPath("access_db") & "\"
db_path = db_dir & "yourdatabasefile.mdb"
fieldname = "your_field"
tablename = "your_table"
connectstr = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & db_path
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM " & tablename
Set oRS = oConn.Execute(qry)
if not oRS.EOF then
while not oRS.EOF
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
"
oRS.movenext
wend
oRS.close
end if
Set oRs = nothing
Set oConn = nothing
%>
SELECT field FROM table WHERE ID = 1
<%=oRS("field")%>
<%
Dim oConn, oRs
Dim qry, connectstr, sDSNDir
Dim db_name, db_username, db_userpassword
Dim dsn_name
dsn_name = "your_dsn_name"
fieldname = "your_fieldname"
tablename = "your_tablename"
'assumes that _dsn exists in the root
sDSNDir = Server.MapPath("/_dsn")
connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM " & tablename
Set oRS = oConn.Execute(qry)
if not oRS.EOF then
while not oRS.EOF
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & " "
oRS.movenext
wend
oRS.close
end if
Set oRs = nothing
Set oConn = nothing
%>
<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual="/adovbs.inc"-->
<html>
<body>
<%
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=access_register.dsn"
objConn.Open
Dim objRS, bolAlreadyExists
If ((Request.Form("firstname") = "") OR (Request.Form("lastname") = "") _
OR (Request.Form("street") = "") OR (Request.Form("city") = "") _
OR (Request.Form("state") = "") OR (Request.Form("zipcode") = "") _
OR (Request.Form("birthdate") = "") OR (Request.Form("email") = "") _
OR (Request.Form("confirmemail") = "") OR (Request.Form("password") = "") _
OR (Request.Form("confirmpassword") = "") OR (Request.Form("question") = "") _
OR (Request.Form("answer") = "") OR (Request.Form("confirmanswer") = "") _
OR (Request.Form("interest") = "") OR (Request.Form("nonewsemail") = "")) Then
Response.Write "<a href='registration.html'>"
Response.Write "You must enter values for all the fields."
Response.Write "</a>"
Else
bolAlreadyExists = False
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "registration", objConn, , adLockOptimistic, adCmdTable
Do While Not (objRS.EOF OR bolAlreadyExists)
If (StrComp(objRS("email"), Request.Form("email"), _
vbTextCompare) = 0) Then
Response.Write "<a href='registration.html'>"
Response.Write "Email address already found in table."
Response.Write "</a>"
bolAlreadyExists = True
End If
objRS.MoveNext
Loop
If Not bolAlreadyExists Then
objRS.AddNew
objRS("firstname") = Request.Form("firstname")
objRS("lastname") = Request.Form("lastname")
objRS("street") = Request.Form("street")
objRS("city") = Request.Form("city")
objRS("state") = Request.Form("state")
objRS("zipcode") = Request.Form("zipcode")
objRS("birthdate") = Request.Form("birthdate")
objRS("email") = Request.Form("email")
objRS("confirmemail") = Request.Form("confirmemail")
objRS("password") = Request.Form("password")
objRS("confirmpassword") = Request.Form("confirmpassword")
objRS("question") = Request.Form("question")
objRS("answer") = Request.Form("answer")
objRS("confirmanswer") = Request.Form("confirmanswer")
objRS("awardprogram") = Request.Form("awardprogram")
objRS("accountnumber") = Request.Form("accountnumber")
objRS("interest") = Request.Form("interest")
objRS("nonewsemail") = Request.Form("nonewsemail")
objRS("hearabout") = Request.Form("hearabout")
objRS.Update
Response.Write "Thank you for registering."
End If
objRS.Close
Set objRS = Nothing
End If
objConn.Close
Set objConn = Nothing
%>
</body>
</html>
<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include virtual="/adovbs.inc"-->
<html>
<body>
<%
Dim oConn, oRs
Dim connectstr, sDSNDir
Dim db_name, db_username, db_userpassword
Dim dsn_name, tablename
dsn_name = "access_register.dsn"
tablename = "registration"
sDSNDir = Server.MapPath("/_dsn")
connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
Dim objRS, bolAlreadyExists
If ((Request.Form("firstname") = "") OR (Request.Form("lastname") = "") _
OR (Request.Form("street") = "") OR (Request.Form("city") = "") _
OR (Request.Form("state") = "") OR (Request.Form("zipcode") = "") _
OR (Request.Form("birthdate") = "") OR (Request.Form("email") = "") _
OR (Request.Form("confirmemail") = "") OR (Request.Form("password") = "") _
OR (Request.Form("confirmpassword") = "") OR (Request.Form("question") = "") _
OR (Request.Form("answer") = "") OR (Request.Form("confirmanswer") = "") _
OR (Request.Form("interest") = "") OR (Request.Form("nonewsemail") = "")) Then
Response.Write "<a href='registration.html'>"
Response.Write "You must enter values for all the fields."
Response.Write "</a>"
Else
bolAlreadyExists = False
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "registration", objConn, , adLockOptimistic, adCmdTable
Do While Not (objRS.EOF OR bolAlreadyExists)
If (StrComp(objRS("email"), Request.Form("email"), _
vbTextCompare) = 0) Then
Response.Write "<a href='registration.html'>"
Response.Write "Email address already found in table."
Response.Write "</a>"
bolAlreadyExists = True
End If
objRS.MoveNext
Loop
If Not bolAlreadyExists Then
objRS.AddNew
objRS("firstname") = Request.Form("firstname")
objRS("lastname") = Request.Form("lastname")
objRS("street") = Request.Form("street")
objRS("city") = Request.Form("city")
objRS("state") = Request.Form("state")
objRS("zipcode") = Request.Form("zipcode")
objRS("birthdate") = Request.Form("birthdate")
objRS("email") = Request.Form("email")
objRS("confirmemail") = Request.Form("confirmemail")
objRS("password") = Request.Form("password")
objRS("confirmpassword") = Request.Form("confirmpassword")
objRS("question") = Request.Form("question")
objRS("answer") = Request.Form("answer")
objRS("confirmanswer") = Request.Form("confirmanswer")
objRS("awardprogram") = Request.Form("awardprogram")
objRS("accountnumber") = Request.Form("accountnumber")
objRS("interest") = Request.Form("interest")
objRS("nonewsemail") = Request.Form("nonewsemail")
objRS("hearabout") = Request.Form("hearabout")
objRS.Update
Response.Write "Thank you for registering."
End If
objRS.Close
Set objRS = Nothing
End If
objConn.Close
Set objConn = Nothing
%>
</body>
</html>
Comment