Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 Reading a SQL return value in an ASP page.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-04 : 18:03:09
Bill writes "I have a login page where I want to pass several values in and have the database (SQL 7.0) verify if a person is allowed to login to the site. I have conditional statements displayed depending on the return value. (I have a WINNT platform, service pack 4, developing on Visual InterDev 6.0, using vbscript. There is no foundational Visual Basic code, strictly asp.)

I am using 2 asp pages, one to gather the input values, includes a form; the second acts as a response for login errors or directs the user to a third page, where the work starts.

The SQL stored procedure works ok (in query analyzer), the asp displays the correct response, but I can't seem to figure a way to connect the two. We have successfully passed parameters to a SQL stored procedure, but cannot read a return value.

My teammate (database admin) and I (web developer) are both relatively new to dynamic web pages. We can't seem to find a reference anywhere that addresses this question directly. Any material found explains each part, says its works well and then presses on, nothing links the two together. Is this approach ok? We're looking for something simple to implement in a hurry! We have to get a prototype up and running in a week!

Dim strLoginStatus, strSQL
Dim dbTdermPeerReview, rsTdermPeerReview, sConn
Dim strUserName, strUserEmail, strUserPWord
Dim strUserFirst, strUserMid, strUserLast

'strLoginStatus = "1"
'strLoginStatus = "2"
'strLoginStatus = "3"
'strLoginStatus = "4"

strUserName = Trim(Request.Form("UserName"))
strPassword = Trim(Request.Form("Password"))
strLoginStatus = ""

'create an ADO database connection.
Set dbTdermPeerReview = server.CreateObject("adodb.connection")

'create a recordset.
Set rsTdermPeerReview = server.CreateObject("adodb.recordset")

'Open the connection using odbc file dsn.
sConn = "Provider=SQLOLEDB.1;Inital Catalog=TdermPeerReview;"
sConn = sConn & "Data Source=ctasql;user=IUSR_CTADEVSVR;Password=CTATDERM"
dbTdermPeerReview.Open(sConn)

strSQL = "Exec prLoginStatus " & "'"_
& strUserName & "','" _
& strPassword & "'"

'execute the SQL statement.
Set rsTdermPeerReview = dbTdermPeerReview.Execute(strSQL)

'gather recordset info. (IsValidUser is the desired return value)
strUserName = rsTdermPeerReview("userName")
strUserFirst = rsTdermPeerReview("firstName")
strUserLast = rsTdermPeerReview("lastName")
strUserMid = rsTdermPeerReview("midName")
strUserPWord = rsTdermPeerReview("password")
strUserEmail = rsTdermPeerReview("email")
strLoginStatus = rsTdermPeerReview("IsValidUser")

'test the response.
Response.Write ("UserName" & strUserName & "_" & "firstName" & strUserFirst & "_" & "UserLast" & strUserLast & "_" & "UserMid" & strUserMid & "_" & "UserPWord" & strUserPWord & "_" & "UserEmail" & strUserEmail) "
   

- Advertisement -