Asp.net (SQL) Simple Login Form

Related searches

I'm kinda new to asp.net but I'm learning fast, tho I cant find any good web forms tutorial for login page written in vb, I'm using the offline application tutorials to learn and I just change the commands, So i've come to a simple error for you guys, the problem is with the dsc.sqlclient, probably there's not such command, but what should I use? Thanks a lot anyway!

   Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        If Page.IsValid Then
            ' check for username & password in the database
            Dim conn As New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=LoginDB;Integrated Security=True")

            ' Get the row corresponding the given username and password
            Dim strSQL As String = "Select * From Users Where Username='" + txtUname.Text + "' and Password = '" + txtPassword.Text + "'"

            Dim dsc As New SqlClient.SqlCommand(strSQL, conn)

            ' Fill the dataset 
            Dim ds As New DataSet()
            dsc.sqlclient.sqlcommand(ds, "Users")

            ' if there no entry then the user is invalid
            If ds.Tables("Users").Rows.Count = 0 Then
                Response.Redirect("Default.aspx")
            Else
                Response.Redirect("login.aspx")
            End If
        End If
    End Sub

Thanks a lot guys, this is the correct answer tho, kbworkshop helped me a lot!

For anyone wanna know this is the code

Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        If Page.IsValid Then
            ' check for username & password in the database
            Dim conn As New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=LoginDB;Integrated Security=True")

            ' Get the row corresponding the given username and password
            Dim strSQL As String = "Select * From Users Where Username='" + txtUname.Text + "' and Password = '" + txtPassword.Text + "'"
            'I recommend not to use * in querys
            Dim dsc As New SqlClient.SqlCommand(strSQL, conn)
            conn.Open()
            Dim dr As SqlDataReader
            dr = dsc.ExecuteReader()

            If dr.HasRows = True Then
                Response.Redirect("Default.aspx")
            Else
                Response.Redirect("login.aspx")
            End If
            conn.Close()
        End If
    End Sub

How To Create Login Page In ASP.NET Web Application Using C# , This article starts with an introduction of the creation of the database and table in SQL Server. Afterwards, it demonstrates how to design ASP.NET� Here Mudassar Ahmed Khan has explained with example how to implement simple user login form in ASP.Net using C# and VB.Net. The login form has been implemented using ASP.Net controls and Forms Authentication. It also has the Remember Me CheckBox feature which allows user to save the credentials when he visits site next time. Complete source code is attached at the end of article. TAGs: ASP.Net

Your code should be something like this:

Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        If Page.IsValid Then
            ' check for username & password in the database
            Dim conn As New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=LoginDB;Integrated Security=True")

            ' Get the row corresponding the given username and password
            Dim strSQL As String = "Select * From Users Where Username='" + txtUname.Text + "' and Password = '" + txtPassword.Text + "'"

            objConn.Open()

            ' Fill the dataset 
            Dim ds As New DataSet("Users")
            Dim daExample As New SqlDataAdapter(strSQL, objConn)
            daExample.Fill(ds, "Users2")

            ' if there no entry then the user is invalid
            If ds.Tables("Users").Rows.Count = 0 Then
                Response.Redirect("Default.aspx")
            Else
                Response.Redirect("login.aspx")
            End If
            objConn.close()
        End If
    End Sub

but you can also take this:

    Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
                If Page.IsValid Then
                    ' check for username & password in the database
                    Dim conn As New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=LoginDB;Integrated Security=True")

                    ' Get the row corresponding the given username and password
                    Dim strSQL As String = "Select * From Users Where Username='" + txtUname.Text + "' and Password = '" + txtPassword.Text + "'"
                    'I recommend not to use * in querys
                    Dim dsc As New SqlClient.SqlCommand(strSQL, conn)

                    Dim dr As SqlDataReader
                    dr = dsc.ExecuteReader()

                     If dr.HasRows = True Then
                        Response.Redirect("Default.aspx")
                     Else
                         Response.Redirect("login.aspx")
                     End If
                End If
       End Sub

How to Create Login Page in Asp.Net With Sql DataBase, How to Create Login and Logout Page in Asp.net using sql server database. Tutorial Duration: 19:47 Posted: Apr 4, 2017 Step 3: Create ASP.NET Login page using C#: To create a new website project, go to “File>New Web Site…” and select “ASP.NET Empty Web Site“. Now, add a web form to design the login page controls and another one to display the welcome message. I designed the login page in a very simple manner.

PLEASE don't create your SELECT statement by pasting text together.

Ugh. Never do that.

You just allow anyone to use "SQL Injection" to log in (and worse) without a password.

how to create login page in asp.net with sql database, This video is help you how to create login page in asp.net with sql database c# In the visiul Duration: 6:54 Posted: Oct 16, 2016 Asp.net (SQL) Simple Login Form. Ask Question Asked 5 years, 8 months ago. Active 5 months ago. Viewed 8k times -2. I'm kinda new to asp.net but I'm learning fast

    Imports System.Data
    Imports System.Data.SqlClient

Partial Class log
    Inherits System.Web.UI.Page

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

        Dim cn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=F:\WebSite1\App_Data\Database.mdf;Integrated Security=True;User Instance=True")
        Dim log As String = "SELECT * FROM login WHERE userid='" & TextBox1.Text & "' AND password='" & TextBox2.Text & "'"

        Session("user") = TextBox1.Text

        Dim cmd As New SqlCommand(log, cn)
        Dim dr As SqlDataReader

        cn.Open()
        dr = cmd.ExecuteReader()

        If dr.HasRows = True Then
            Response.Redirect("showdata.aspx")
        Else
            Response.Redirect("log.aspx")

        End If

    End Sub

End Class

Simple login form example in asp.net Check Username and , NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles In this post I will explain how to implement simple login form using asp.net and I will Once data entered in table design your aspx page like this� I am trying to make a simple login form in my asp.net page(I had a html page and now I am trying to make it to asp.net). It should take the entered username and password and connect to the mssql database.

You can use SqlDataAdapter class to fill your dataset:

SqlConnection conn = new SqlConnection("My ConnectionString");
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = SQL;
da.SelectCommand = cmd;
DataSet ds = new DataSet();

conn.Open();
da.Fill(ds);
conn.Close();

VB.Net:

Dim conn As New SqlConnection("My ConnectionString")
Dim da As New SqlDataAdapter()
Dim cmd As SqlCommand = conn.CreateCommand()
cmd.CommandText = SQL
da.SelectCommand = cmd
Dim ds As New DataSet()

conn.Open()
da.Fill(ds)
conn.Close()

How To Create ASP.net Login Page Using C# with SQL Database , In this tutorial, you will learn how to create a simple ASP.NET login page using C# and SQL database. Download source code from GitHub. How To Create a Login Form Step 1) Add HTML: Add an image inside a container and add inputs (with a matching label) for each field. Wrap a <form> element around them to process the input. You can learn more about how to process input in our PHP tutorial.

So, If you have not even created your Asp.net Core project then your first step is to create an Empty project using this command. dotnet new Web & don’t forget to create these Four folders “Controllers”, “Models”, “Views” & “wwwroot”.

Comments
  • Is it custom membership? Identity?
  • Yes custom membership but I want just a simple login form for now.
  • one tip: you can declare the Connection values in the web.config archive regars alexandros!!
  • I found the answer your code helped me a lot but with some minor tweaks, thanks a lot mate!!
  • @AlexandrosStark you're welcome !! luck!! pd: mark the answer!!