Syntax error: Missing operand after '@' operator.

farid

Member
Joined
May 24, 2003
Messages
9
I am trying to test form authentication in asp.net using xml file but I got this error
"Syntax error: Missing operand after @farid operator.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SyntaxErrorException: Syntax error: Missing operand after @farid operator.

Source Error:


Line 36: Users = ds.tables(0)
Line 37: Dim Matches() as DataRow
Line 38: Matches = Users.Select(cmd)
Line 39: If Matches.length >0 Then
Line 40: Dim row as DataRow


Source File: c:\inetpub\wwwroot\asp\login.aspx Line: 38
"

the login.aspx page code
Code:
<%@ Import Namespace="System.XML" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data.OleDB" %>
<%@ Import Namespace="System.Data" %>
<%@ Page Language="vb" debug="True"%>
<HTML>
<HEAD>
<TITLE>Session 13 Cookie Authentication </TITLE>
<SCRIPT LANGUAGE="VB" RUNAT="Server">
Sub btnLogin_Click(ByVal Sender As Object, ByVal E As EventArgs)
Select Case ValidateUserXML(txtusername.text,txtpassword.text)
Case "Success"
FormsAuthentication.RedirectFromLoginPage (txtusername.text,chkPersistForms.Checked)
Case "PasswordFailed"
lblMessage.Text = "Sorry your password verification for the user " & txtusername.text &" failed."
Case "NoSuchUser"
Response.Redirect("adduser/adduser.aspx?username=" & txtusername.text)
End Select
End Sub
Sub btnAddNewUser_Click(ByVal Sender As Object, ByVal E As EventArgs)
Response.Redirect("adduser/adduser.aspx?username=Enter User Name")
End Sub
Function ValidateUserXML(ByVal username as String, ByVal password as String) as String
Dim cmd as String
cmd = "UserEmail=
 
Last edited by a moderator:
:eek:

You should probably clean up your code so those who are trying to help can read it. :)

Anyway, obviously theres an error with the emails when using @. It seems like its treating it as a stored procedure variable and wants you to set something to it (ie; @farid = 32)

How to fix this, I dont know exactly. Im having a hard time sifting through your code so I cant give any real suggestions.

From what Ive grasped by quickly glancing over, you should use a replace on your cmd string before using it so it can use the @ appropriately. Something like this;

cmd = cmd.Replace("@", " + @ + ")

The replacement for @ would be + @ +
Hopefully it will bypass the stored procedure error and just use it as regular string concatenation.
 

Similar threads

Back
Top