login to MySQL database

asp.net , mysql Malaysia
  • 15 years ago

    Hello all,

    I know this is a very common question but I can't really find the right solution for this error. I wanted to create a login form where authorized user will be redirected to authorized page. I'm using MySQL database. I'm really new with both asp.net and MySQL. Confused [*-)]Sad [:(]

     

    Private Sub btLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btLogin.Click

    Dim strCon = ("DRIVER={MySQL ODBC 3.51 Driver};server=localhost; uid=root; password=kucemari; database=plantsnherbs")

    Dim objcon As New OdbcConnection(strCon)

    Dim objCommand As New OdbcCommand("SELCET adminid FROM admin WHERE adminid = @adminid AND password = @password ", objcon)

    objCommand.Parameters.Add("@adminid", OdbcType.TinyInt).Value = Me.tbadminid.Text

    objCommand.Parameters.Add("@password", OdbcType.VarChar).Value = Me.tbpassword.Text

    objcon.Open()

    If tbadminid.Text = "@adminid" And tbpassword.Text = "@password" Then   --> I'm stuck with this!

    Response.Cookies("FirstName").Value = tbadminid.Text

    Response.Redirect("http://localhost/plantsnherbs/adminpage.aspx")

    Else

    Response.Write("Login failed. Please enter correct Admin ID and password")

    End If

    objcon.Close()

    End Sub

     

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There are only 3 numbers of interest to a computer scientist: 1, 0 and infinity”