Hi,
I am having a problem tryin to open the connection to a database the
nretreiving the informaiton based on the entry of an email address and
a password for authentication from the database. Here is my code, can
enyone help me out and fix it with the right peices?
Private Sub Submit1_ServerClick(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Submit1.ServerClick
Dim db As New BWMDB.Database(Session("Database"))
Dim cn
cn = db.Connection.ConnectionString.ToString()
Dim strSQL As String
strSQL = "SELECT * FROM BWM$Customer WHERE E-Mail = @E-Mail
AND Password = @Password"
Dim oCommand As New SqlCommand(strSQL, cn)
' Add parameters for the query.
oCommand.Parameters.Add("@E-Mail", Textfield1.Text.Trim())
oCommand.Parameters.Add("@Password", Textfield2.Text.Trim())
Dim dr As SqlDataReader
dr = db.GetDataReader(strSQL)
'dr = oCommand.ExecuteReader(System.Data.CommandBehavior .CloseConnection)
Try
If dr.HasRows Then
' The Email address and password match
' Set session variables
Me.Request.UrlReferrer.ToString()
Else
' Username and password DO NOT match
Response.Write("<script language=javascript>")
Response.Write("function alertUser()")
Response.Write("{alert('Email Address and Password do
not match our records')}")
Response.Write("</script")
End If
Catch ex As Exception
' Handle exceptions here
Label1.Text = "Could not retrieve the information: " &
ex.Message
Finally
dr.Close()
'db.Connection.Close()
cn.Close()
cn.Dispose()
oCommand.Dispose()
End Try
End Sub
Thanks
TG