locked
ADO.net RRS feed

  • Question

  • Imports

     

    System.Data.SqlClient

    Imports

     

    System.Data

    Private

     

    Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

     

    Dim CN As New SqlConnection("Data Source=HMA-CEF7A68A078\SQLEXPRESS;Initial Catalog=Student;Integrated Security=True")

     

    Dim CMD As SqlCommand

     

    'Dim strSql As String

     

    Dim Dr As SqlDataReader

     

    'Dim dr As New SqlDataAdapter

     

    Dim i As Integer

     

    'CN.ConnectionString = "Data Source=HMA-CEF7A68A078\SQLEXPRESS;Initial Catalog=Student;Integrated Security=True"

     

    'CN.ConnectionString = "Data Source=HMA-CEF7A68A078\SQLEXPRESS;Initial Catalog=Student;Integrated Security=True"

    CN.Open()

     

    'strSql = "select * from Login"

    CMD =

    New SqlCommand("select * from Login", CN)

     

    'Dr = New SqlDataReader(CMD)

    Dr = CMD.ExecuteReader

    CMD.ExecuteNonQuery()

    i = 0

     

    While Dr.Read

     

    If (Dr("UserName") = TextBox1.Text) And ("Password") = TextBox2.Text Then

    i = 1

     

    Exit While

     

    Else

    i = 0

     

     

    End If

     

    End While

     

    If i = 1 Then

    MessageBox.Show(

    "Valid Login")

    TextBox1.Clear()

    TextBox2.Clear()

     

    Dim f2 As New Form2

     

    Me.Hide()

    f2.Show()

     

    Else

    MsgBox(

    "Invalid Login")

    TextBox1.Clear()

    TextBox2.Clear()

     

    End If

    CN.Close()

     

    End Sub

    Tuesday, August 25, 2009 8:49 AM