net_susan
asked on
dr = cmd.ExecuteReader()
I have an error on this line:
dr = cmd.ExecuteReader()
Incorrect syntax near '='.
What's wrong with my code?
Private Sub verifycus()
Dim objConn As New SqlConnection("Server=myho st; Initial Catalog=mydb; User ID=myid; Password=mypw")
objConn.Open()
try
dim VEmail, VGPassword
Dim cmd As New SqlCommand("Select * FROM CustomerInfo WHERE Email= '" &VEmail &"' AND VGPassword = "&VPassword, objconn)
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
While dr.Read
Response.Write(dr.Item("Em ail"))
End While
dr.Close
finally
objConn.Close()
objConn.Dispose()
end try
End Sub
dr = cmd.ExecuteReader()
Incorrect syntax near '='.
What's wrong with my code?
Private Sub verifycus()
Dim objConn As New SqlConnection("Server=myho
objConn.Open()
try
dim VEmail, VGPassword
Dim cmd As New SqlCommand("Select * FROM CustomerInfo WHERE Email= '" &VEmail &"' AND VGPassword = "&VPassword, objconn)
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
While dr.Read
Response.Write(dr.Item("Em
End While
dr.Close
finally
objConn.Close()
objConn.Dispose()
end try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Scolja,
BC30451: Name 'Email' is not declared.
BC30451: Name 'Email' is not declared.
net_susan,
I don't have "Email" anywhere, just hanging out... maybe you forgot the V in front of it on this line?
cmd.Parameters.Add(New SqlParameter("@email", VEmail))
-- Jason
I don't have "Email" anywhere, just hanging out... maybe you forgot the V in front of it on this line?
cmd.Parameters.Add(New SqlParameter("@email", VEmail))
-- Jason
you probably just need to initialize dr with 'New'.
Dim dr As New SqlDataReader
Dim dr As New SqlDataReader
Dim cmd As New SqlCommand("Select * FROM CustomerInfo WHERE Email= '" &VEmail &"' AND VGPassword = "&VPassword, objconn)
on this line, why do you have double quotes before &VEmail? should just be
WHERE Email = " & VEmail & " AND VGPassword = " & VPassword, objConn)
on this line, why do you have double quotes before &VEmail? should just be
WHERE Email = " & VEmail & " AND VGPassword = " & VPassword, objConn)
craskin,
Actually, you can't instantiate a SqlDataReader, it has to be assigned.
-- Jason
Actually, you can't instantiate a SqlDataReader, it has to be assigned.
-- Jason
ASKER
Jason,
I must have messed up somewhere?
Private Sub verifycus()
Dim objConn As New SqlConnection("Server=myho st; Initial Catalog=mydb; User ID=myid; Password=mypw")
objConn.Open()
try
dim VEemail, VPassword
Dim cmd As New SqlCommand("SELECT * FROM CustomerInfo WHERE Email= @VEemail AND VGPassword = @Vpassword", objconn)
cmd.Parameters.Add(New SqlParameter("@email", VEemail))
cmd.Parameters.Add(New SqlParameter("@VGpassword" , VPassword))
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
While dr.Read
Response.Write(dr.Item("Em ail"))
End While
dr.Close
finally
objConn.Close()
objConn.Dispose()
end try
End Sub
I must have messed up somewhere?
Private Sub verifycus()
Dim objConn As New SqlConnection("Server=myho
objConn.Open()
try
dim VEemail, VPassword
Dim cmd As New SqlCommand("SELECT * FROM CustomerInfo WHERE Email= @VEemail AND VGPassword = @Vpassword", objconn)
cmd.Parameters.Add(New SqlParameter("@email", VEemail))
cmd.Parameters.Add(New SqlParameter("@VGpassword"
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
While dr.Read
Response.Write(dr.Item("Em
End While
dr.Close
finally
objConn.Close()
objConn.Dispose()
end try
End Sub
net_susan,
Well, from looking at this code... I'm not sure what you're trying to do... you declare your two variables VEemail and VPassword immediately before the New SqlCommand() line. But then you pass those two variables into the SQL, but they're going to be blank, right? You haven't assigned a value to them.....
So I'm not sure how you expect to receive any results. Maybe you can clear this up for me....
-- Jason
Well, from looking at this code... I'm not sure what you're trying to do... you declare your two variables VEemail and VPassword immediately before the New SqlCommand() line. But then you pass those two variables into the SQL, but they're going to be blank, right? You haven't assigned a value to them.....
So I'm not sure how you expect to receive any results. Maybe you can clear this up for me....
-- Jason
ASKER
Sorry. I'm passing them from the previous page (or at least trying to).
Protected Sub signinSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("next.as px?VEemail ='"+syEmai l.Text +"'&VPassword='"+syPasswor d.Text+"'" )
End Sub
That page works.
Protected Sub signinSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("next.as
End Sub
That page works.
Then you need to retrieve them on your new page:
Dim VEemail As String = Request.QueryString("VEema il")
Dim VPassword As String = Request.QueryString("VPass word")
Those 2 lines should replace this one:
dim VEemail, VPassword
-- Jason
Dim VEemail As String = Request.QueryString("VEema
Dim VPassword As String = Request.QueryString("VPass
Those 2 lines should replace this one:
dim VEemail, VPassword
-- Jason
ASKER
Thanks, new q coming soon. :)
ASKER
Dim cmd As New SqlCommand("Select * FROM CustomerInfo WHERE Email= '" &VEmail &"' AND VGPassword = ' " & VPassword & " ' ", objconn)