Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Error when trying to login using try...catch

$
0
0

Getting an error in my try..catch:

An expression of non-boolean type specified in a context where a condition is expected, near ','
         Try
            Dim connStr, cmdStr As String
            connStr = "server=db457994917.db.1and1.com;initial catalog=db457994917;uid=dbo457994917;pwd=electrical"
            cmdStr = "SELECT [ids] FROM [sessionregister] WHERE [username=@User],[password=&Pass];"
            Using conn As New SqlConnection(connStr)
                Using cmd As New SqlCommand(cmdStr, conn)
                    conn.Open()
                    cmd.Parameters.AddWithValue("@User", User1)
                    cmd.Parameters.AddWithValue("@Pass", Pass1)
                    cmd.ExecuteNonQuery()
                    Using myreader = cmd.ExecuteReader()
                        ids = myreader(0).ToString()
                    End Using
                    If ids = "" Then
                        TextBox5.Text = "Reenter Username and Password"
                        Exit Sub
                    ElseIf ids <> "" Then
                        Session("ids") = ids
                    Else
                        Exit Sub
                    End If
                    conn.Close()
                    cmd.Dispose()
                    conn.Dispose()
                End Using
            End Using
        Catch ex As Exception
            TextBox5.Text = ex.Message
            Exit Sub
        End Try


User1 and Pass1 are defined earlier in the program.


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>