Prevent saving login details after successful login for specific user in ASP.Net using VB.Net

makumbi
 
on Dec 06, 2022 11:13 PM
526 Views

How can i make sure that the login details are not saved after a successful login?

How can i archive i would the users to login but i do not want the login details to be saved on the login form

please help

If String.IsNullOrEmpty(Account.Text) Then
    Dim sqlConnection12 As New SqlConnection(constr)
    Using Cont As New SqlConnection(constr)
        Cont.Open()
        Using cmd As New SqlCommand
            cmd.Connection = Cont
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = "createaccounts"
            cmd.Parameters.Add("@n", SqlDbType.NVarChar).Value = Names.Text
            cmd.Parameters.Add("@st", SqlDbType.NVarChar).Value = DropDownList3.SelectedItem.Text
            cmd.Parameters.Add("@c", SqlDbType.NVarChar).Value = DropDownList1.SelectedItem.Value
            cmd.Parameters.Add("@s", SqlDbType.NVarChar).Value = Stream.Text
            cmd.ExecuteReader()
            Cont.Close()
 
        End Using
    End Using
    BindGrid()
    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "showalert", "alert('Account Created Successfully');", True)
 
 
Else
    Dim sqlConnection12 As New SqlConnection(constr)
    Using Cont As New SqlConnection(constr)
        Cont.Open()
        Using cmd As New SqlCommand
            cmd.Connection = Cont
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = "createaccountsupdate"
            cmd.Parameters.Add("@n", SqlDbType.NVarChar).Value = Names.Text
            cmd.Parameters.Add("@st", SqlDbType.NVarChar).Value = DropDownList3.SelectedItem.Text.ToString().Replace(" ", "")
            cmd.Parameters.Add("@c", SqlDbType.NVarChar).Value = DropDownList1.SelectedItem.Value.ToString().Replace(" ", "")
            cmd.Parameters.Add("@s", SqlDbType.NVarChar).Value = Stream.Text.ToString().Replace(" ", "")
            cmd.Parameters.Add("@a", SqlDbType.NVarChar).Value = Account.Text
            cmd.ExecuteReader()
            Cont.Close()
 
        End Using
    End Using
    BindGrid()
    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "showalert", "alert('Account Updated Successfully');", True)
 
End If

 

PROCEDURE [dbo].[createaccounts] @n nvarchar(150),@st nvarchar(50),@c nvarchar(50),@s nvarchar(50) AS
begin
    if @st='Student'
     
    exec createaccountsstudent @n,@st,@c,@s
         
else
 
    exec createaccountsOthers @n,@st
end

PROCEDURE [dbo].[createaccountsstudent] @n nvarchar(150),@st nvarchar(50),@c nvarchar(50),@s nvarchar(50)AS
begin
     
INSERT INTO Accounts( NAME,[TYPE],[Class],stream,Dates)
Select  UPPER(@n),@st,@c,Upper(@s),CONVERT(datetime,GETDATE(),103)
update Accounts set Account = Right(str(Year(Getdate())),2)+'-0000'+ LTRIM(str(accountskey)) where accountskey between 0 and 9 and account Is Null
 
update Accounts set Account = Right(str(Year(Getdate())),2)+'-000'+ LTRIM(str(accountskey))  where accountskey between 10 and 99 and account Is Null
 
update Accounts set Account = Right(str(Year(Getdate())),2)+'-00'+ LTRIM(str(accountskey))  where accountskey between 100 and 999 and account Is Null
 
update Accounts set Account = Right(str(Year(Getdate())),2)+'-0'+ LTRIM(str(accountskey))  where accountskey between 1000 and 9999 and account Is Null
update Accounts set Account = Right(str(Year(Getdate())),2)+'-'+ LTRIM(str(accountskey))  where accountskey between 10000 and 99999 and account Is Null
end

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Dec 07, 2022 04:49 AM

Check the below code.

' Here you need to check your user detail.
If Account.Text! = "YourUserDetails" Then
    If String.IsNullOrEmpty(Account.Text) Then
        Dim sqlConnection12 As New SqlConnection(constr)
        Using Cont As New SqlConnection(constr)
            Cont.Open()
            Using cmd As New SqlCommand
                cmd.Connection = Cont
                cmd.CommandType = CommandType.StoredProcedure
                cmd.CommandText = "createaccounts"
                cmd.Parameters.Add("@n", SqlDbType.NVarChar).Value = Names.Text
                cmd.Parameters.Add("@st", SqlDbType.NVarChar).Value = DropDownList3.SelectedItem.Text
                cmd.Parameters.Add("@c", SqlDbType.NVarChar).Value = DropDownList1.SelectedItem.Value
                cmd.Parameters.Add("@s", SqlDbType.NVarChar).Value = Stream.Text
                cmd.ExecuteReader()
                Cont.Close()

            End Using
        End Using
        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "showalert", "alert('Account Created Successfully');", True)
    Else
        Dim sqlConnection12 As New SqlConnection(constr)
        Using Cont As New SqlConnection(constr)
            Cont.Open()
            Using cmd As New SqlCommand
                cmd.Connection = Cont
                cmd.CommandType = CommandType.StoredProcedure
                cmd.CommandText = "createaccountsupdate"
                cmd.Parameters.Add("@n", SqlDbType.NVarChar).Value = Names.Text
                cmd.Parameters.Add("@st", SqlDbType.NVarChar).Value = DropDownList3.SelectedItem.Text.ToString().Replace(" ", "")
                cmd.Parameters.Add("@c", SqlDbType.NVarChar).Value = DropDownList1.SelectedItem.Value.ToString().Replace(" ", "")
                cmd.Parameters.Add("@s", SqlDbType.NVarChar).Value = Stream.Text.ToString().Replace(" ", "")
                cmd.Parameters.Add("@a", SqlDbType.NVarChar).Value = Account.Text
                cmd.ExecuteReader()
                Cont.Close()

            End Using
        End Using
        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "showalert", "alert('Account Updated Successfully');", True)
    End If
    BindGrid()
End If