need help fixing data retrieval

  • Thread starter Thread starter TG
  • Start date Start date
T

TG

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
 
TG

In addition to Bill, why do you not use dotNet code to show the alert.

Maybe you can use this sample I made once and sand to Dave

http://groups.google.com/groups?selm=e#[email protected]

This was to show how a shared class can be used in ASPNET however you can
use that of course as well without that. But it is a nice sample as well how
to do use that shared class in my opinion.

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top