.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Login form using vb.net with sql sarver

Posted By:laptop charles       Posted Date: July 25, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

Sql sarver validation the username and pasword.

*Create the data base using sql server.
*User name and password.
*Then insert the user name and password.
*Copy the bellow coding then run.
*It contain two textbox and two label.
*The text box name is txt1 and txt2.
*Then give the connection string.
Imports System.Data
Imports System.Data.SqlClient

Public Class Form1
    Dim con As SqlConnection
    Dim cmd As SqlCommand
    Dim dr As SqlDataReader
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        con = New SqlConnection("server=ANONYMOUS;Trusted_Connection=yes;database=charles")
    End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        cmd = New SqlCommand("select * from charl where UserName=@nam and PassWord=@pwd ", con)
        cmd.Parameters.AddWithValue("@nam", txt1.Text)
        cmd.Parameters.AddWithValue("@pwd", txt2.Text)

        dr = cmd.ExecuteReader()
        If (dr.Read()) Then

            MsgBox("hai charles welcome")


        End If

    End Sub
End Class


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend