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
 General SQL Server Forums
 New to SQL Server Programming
 VBScript Error

Author  Topic 

mastajbl
Starting Member

42 Posts

Posted - 2009-04-27 : 10:41:42
I know this is a SQL forum, but the help provided here is the best I have come acrossed so I figured maybe someone here could help.

I am getting an "Unterminated String Constant" during my login redirect script. I have tried several different combinations and usually receive a syntax error when i do that. It is saying this error is occuring

Microsoft VBScript compilation error '800a0409'
Unterminated string constant
/jblproduction/loginauth2BU.asp, line 30
MM_redirectLoginSuccess = "<%=(RS_Login.Fields.Item(Link).Value)
----------------------------------------------------------------^
Here is my code, if you have any ideas what I am missing I would appreciate the help.


1 <%@LANGUAGE="VBSCRIPT"%>
2 <!--#include virtual="/DCG/Connections/catalog.asp" -->
3 <%
4 Dim RS_Login
5 Dim RS_Login_cmd
6 Dim RS_Login_numRows
7
8 Set RS_Login_cmd = Server.CreateObject ("ADODB.Command")
9 RS_Login_cmd.ActiveConnection = MM_catalog_STRING
10 RS_Login_cmd.CommandText = "SELECT Link FROM login"
11 RS_Login_cmd.Prepared = true
12
13 Set RS_Login = RS_Login_cmd.Execute
14 RS_Login_numRows = 0
15 %>
16 <%
17 ' *** Validate request to log in to this site.
18 MM_LoginAction = Request.ServerVariables("URL")
19 If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
20 MM_valUsername = CStr(Request.Form("userId"))
21 If MM_valUsername <> "" Then
22 Dim MM_fldUserAuthorization
23 Dim MM_redirectLoginSuccess
24 Dim MM_redirectLoginFailed
25 Dim MM_loginSQL
26 Dim MM_rsUser
27 Dim MM_rsUser_cmd
28
29 MM_fldUserAuthorization = "Access"
30 MM_redirectLoginSuccess = "<%=(RS_Login.Fields.Item(Link).Value)%>"
31
32 MM_redirectLoginFailed = "jblcontact.html"
33 MM_loginSQL = "SELECT UserID, Password"
34 If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
35 MM_loginSQL = MM_loginSQL & " FROM login WHERE UserID = ? AND Password = ?"
36 Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
37 MM_rsUser_cmd.ActiveConnection = MM_catalog_STRING
38 MM_rsUser_cmd.CommandText = MM_loginSQL
39 MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 50, MM_valUsername) ' adVarChar
40 MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 50, Request.Form("Password")) ' adVarChar
41 MM_rsUser_cmd.Prepared = true
42 Set MM_rsUser = MM_rsUser_cmd.Execute
43 If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
44 ' username and password match - this is a valid user
45 Session("MM_Username") = MM_valUsername
46 If (MM_fldUserAuthorization <> "") Then
47 Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
48 Else
49 Session("MM_UserAuthorization") = ""
50 End If
51 if CStr(Request.QueryString("accessdenied")) <> "" And false Then
52 MM_redirectLoginSuccess = Request.QueryString("accessdenied")
53 End If
54 MM_rsUser.Close
57 Response.Redirect(MM_redirectLoginSuccess)
58 End If
59 MM_rsUser.Close
60 Response.Redirect(MM_redirectLoginFailed)
61 End If
62 %>

whitefang
Enterprise-Level Plonker Who's Not Wrong

272 Posts

Posted - 2009-04-27 : 11:34:19
MM_redirectLoginSuccess = "<%=(RS_Login.Fields.Item(Link).Value)%>"
the Value property is returning a extra " which causes an exception. You need to escape it by doing a replace on " with "". I think it's RS_Login.Fields.Item(Link).Value.replace(""","""");
Go to Top of Page

mastajbl
Starting Member

42 Posts

Posted - 2009-04-27 : 12:04:55
Microsoft VBScript compilation error '800a0401'

Expected end of statement

/jblproduction/loginauth2BU.asp, line 30

MM_redirectLoginSuccess = "<%=(RS_Login.Fields.Item(Link).Value.replace(""","""");
--------------------------------------------------------------------------^

[CODE]MM_redirectLoginSuccess = "<%=(RS_Login.Fields.Item(Link).Value.replace(""","""");%>"[/CODE]

****Edit
Forgot to double quotes. Now receiving this which isnt adding up to me.

Microsoft VBScript compilation error '800a0408'

Invalid character

/jblproduction/loginauth2BU.asp, line 30

MM_redirectLoginSuccess = ""<%=(RS_Login.Fields.Item(Link).Value.replace(""","""");
------------------------------^






Go to Top of Page

whitefang
Enterprise-Level Plonker Who's Not Wrong

272 Posts

Posted - 2009-04-27 : 12:15:29
MM_redirectLoginSuccess = ""<%=(RS_Login.Fields.Item(Link).Value.replace(""","""");

You have double quotes outside, it's incorrect. Should be:
MM_redirectLoginSuccess = "<%=(RS_Login.Fields.Item(Link).Value.replace(""","""")%>"

Also, why don't you do it this way:
MM_redirectLoginSuccess = RS_Login.Fields.Item(Link).Value ?????
Go to Top of Page

mastajbl
Starting Member

42 Posts

Posted - 2009-04-27 : 12:41:21
To ur first reply, MM_redirectLoginSuccess = "<%=(RS_Login.Fields.Item(Link).Value.replace(""","""")%>"
I receive an "Unexpected Character" error for the , between the (""","""")

For the second one, it would be like this RS_Login.Fields.Item("Link").Value, and I receive this error. I tried to go the route of the lesser of two evils...

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'Response.Redirect'

/jblproduction/loginauth2BU.asp, line 57

Dropping the quotes around ("link") i receive this error..

ADODB.Fields error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/jblproduction/loginauth2BU.asp, line 30

Go to Top of Page

mastajbl
Starting Member

42 Posts

Posted - 2009-04-27 : 14:33:05
OK I fixed the issue with the RS_Login.Fields.Item("Link").Value with your help, but it only uses the first field in link column. I have another issue though that has arrived so i will start a new topic for that.

Thanks for your help on this one!!

Go to Top of Page
   

- Advertisement -