AltaSens
asked on
(VB2008) SqlException was unhandled: must declare the scalar variable "@FFEmailAlias"
I am using Visual Studio 2008 (VB2008) and trying to code a procedure which will return a record from the database using a parameter. When I execute this code, I get a SqlException error. I have tried a number of things from articles found here and still cannot get this to work.
HELP?!
Sub ValidateUser()
'get strUserName from environment
strUserName = Environ("USERNAME")
'look for strUserName in Employee Table
Dim EmailAliasParm As New SqlParameter("@FFEmailAlias", strUserName)
'EmailAliasParm.ParameterName = "@FFEmailAlias"
'EmailAliasParm.Value = strUserName
connection.ConnectionString = connectionString
selectStatement = "SELECT * FROM Employee WHERE EmailAlias = @FFEmailAlias"
Dim selectCommand As New SqlCommand(selectStatement, connection)
Try
connection.Open()
Dim reader As SqlDataReader = selectCommand.ExecuteReader(CommandBehavior.SingleRow)
If reader.Read Then
intEmployeeID = reader("ID")
intManagerID = reader("ManagerID")
strFirstName = reader("FirstName")
strLastName = reader("LastName")
strEmailAlias = reader("EmailAlias")
Else
MsgBox("no data")
End If
Catch ex As SqlException
Throw ex
Finally
connection.Close()
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
doh!
yes, that worked. THANK YOU THANK YOU THANK YOU!
yes, that worked. THANK YOU THANK YOU THANK YOU!
ASKER
Open in new window