|
Subject:
|
validating Login Forms
|
|
Posted By:
|
hanumanth.sr
|
Post Date:
|
4/19/2006 12:32:14 AM
|
Hai, I am doing one Project(WindowsApplication using VB.NET) I want to check the valid name with valid password which is stored in SQL Server Database.
Plz send me a sample coding for this one..
|
|
Reply By:
|
al-hijjawi
|
Reply Date:
|
4/19/2006 2:34:53 PM
|
no problem here see the following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As New SqlConnection Dim cmd As New SqlCommand Dim No As String Dim p As SqlParameter con.ConnectionString = "user id=UserName;data source=(local);persist security info=True;initial catalog=DatabaseName;password=PassWord" cmd.Connection = con cmd.CommandType = CommandType.Text p = cmd.Parameters.Add("@user", Convert.ToInt16(0)) p = cmd.Parameters.Add("@pass", 1) cmd.Parameters("@user").Value = txtuser.Text cmd.Parameters("@pass").Value = txtpassword.Text cmd.CommandText = "SELECT AdminstratorNo, UserName, PassWord FROM Adminstrator WHERE (UserName =@user and PassWord=@pass)" cmd.Connection.Open() No = cmd.ExecuteScalar() If (No = "") Then message.Text = "Error" Else 'Go to the next form End If cmd.Connection.Close() End Sub
|