Print Page | Close Window

ASP problem with SQL DB

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=24869
Printed Date: 29 March 2026 at 8:17am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP problem with SQL DB
Posted By: ainsworth14
Subject: ASP problem with SQL DB
Date Posted: 22 November 2007 at 9:58am
Hi

I have a problem with some ASP script. The code works a treat on my testing server with an access database but fails to work with the SQL database i have on a live server - keeps saying incorrect username

do i need to amend any code in this?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/fr_record_webtest.asp" -->
<%   
' variables
dim cnStr
dim rcSet
dim frmUsername
dim frmPassword
dim sqlStr

'store form input into variables
frmUsername = Request.Form("form_username")
frmPassword = Request.Form("form_password")

'create connection and recordset objects
Set cnStr = Server.CreateObject("ADODB.Connection")
Set rcSet = Server.CreateObject("ADODB.Recordset")

' defining database connection (connectionstring.asp)
Set cnStr = Server.CreateObject("ADODB.Connection")
cnStr.open strConnectionString

' execute sql and open as recordset
sqlStr = "Select * From adminprofiles where user = '" _
            & frmUsername & "' and password = '" & frmPassword & "'"

' Opens the returned values from the SQL as a recordset, ready for iteration by ASP
set rcSet = cnStr.Execute(sqlStr)

' validate variables against database
If (not rcSet.BOF) and (not rcSet.EOF) then
session("validated_user") = frmUsername
response.write "<h1>Login successful!</h1>"
response.write "<p>Welcome " & rcSet.fields(1) & "</p>"
Session("Authenticated") = 1
response.Redirect ("frr_admin_default.asp")
else
response.write "incorrect username and/or password"
end if
%>
<%
rcSet.Close()
Set rcSet = Nothing
%>




Replies:
Posted By: shakir
Date Posted: 05 December 2007 at 4:20pm
what type of connection you are using, describe "strConnectionString", give the connection string values also.. then i can suggest u


Posted By: jamie.townsend
Date Posted: 07 December 2007 at 11:38am
Have you been able to connect to the SQL Server using just teh conection string without the rest of the code ??
 
Sounds like your connection to the database is not being set correctly.
Check the username/password as this is most likely the problem you are having, if you paste your error here we could advise you further.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net