visual basic login code

code for login form for validation

Page 1 of 1

10 Replies - 26063 Views - Last Post: 09 March 2010 - 06:46 PM Rate Topic: -----

#1 rups  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 8
  • Joined: 10-July 06

visual basic login code

Posted 10 July 2006 - 05:40 PM

i want to write a code for login form for validation.... i m creating login page where user can enter his name and password.i am using microsoft acess database.

how can i compaire the data which is enter by user and the data which is stored in database for validation.

can anybody give me some code...

This post has been edited by rups: 10 July 2006 - 07:07 PM

Is This A Good Question/Topic? 0
  • +

Replies To: visual basic login code

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: visual basic login code

Posted 10 July 2006 - 06:28 PM

Can you specify which database you'll be using? Deoending on the DB, the connection strings will be different, although the methodology for login validation is the same. Also, will you be storing the passwords in an encrypted format?
Was This Post Helpful? 2

#3 rups  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 8
  • Joined: 10-July 06

Re: visual basic login code

Posted 10 July 2006 - 07:09 PM

View PostAmadeus, on 10 Jul, 2006 - 05:20 PM, said:

Can you specify which database you'll be using? Deoending on the DB, the connection strings will be different, although the methodology for login validation is the same. Also, will you be storing the passwords in an encrypted format?


i am using microsoft Acess database.
Was This Post Helpful? 1

#4 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: visual basic login code

Posted 11 July 2006 - 02:50 AM

You will need to encrypt it.
If you place the password in the Access Database File,simply opening it will reveal the password.

If you protect the MDB File with a Password, you'll have to supply it in the ConnectionString. That Connection String is placed in the .data Section of your final executable file and can be easily read by anyone.

What is the table format of your database?
Was This Post Helpful? 0
  • +
  • -

#5 Srrupert  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-March 07

Re: visual basic login code

Posted 23 March 2007 - 06:56 AM

Option Explicit
Public myConnection As ADODB.Connection
Public myDB As ADODB.Recordset

public sub SEND()
dim strSQL as string

  Set myConnection = New ADODB.Connection
	'myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\path\file.mdb;Persist Security Info=true"
	myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\path\file.mdb;Persist Security Info=true"
	myConnection.Open

' File.mdb MDB is the Access Database, TABLE is the table in the database, field"" is the fields, and the TEXT  is the data entered
	strSQL = "Insert Into TABLE (field1, field2, field3, field4, field5, field6, field7, field8) values ('"
	strSQL = strSQL & TEXT1.text & "','"
	strSQL = strSQL & TEXT2.text  & "','"
	strSQL = strSQL & TEXT3.text  & "','"
	strSQL = strSQL & TEXT4.text  & "','"
	strSQL = strSQL & TEXT5.text  & "','"
	strSQL = strSQL & TEXT6.text  & "','"
	strSQL = strSQL & TEXT7.text  & "','"
	strSQL = strSQL & TEXT8.text & "');"

	myConnection.Execute (strSQL)
end sub

public sub READ()
DIM UserName as string
DIM Student as string

' Reads all database entries per line

	Do Until myDB.EOF
If myDB("field1") = TEXT1.Text Then
			UserName = (myDB("field2"))
			Student = (myDB("field2"))
			GoTo 98
end if
		myDB.MoveNext
	Loop
98:
end sub



Hope this helps

just call this routine and it will insert. This is one easy way to do this that you can read simply


The user that is logged into the application PC must have write access to the file were the database is held.
I have other queries that use a module for reference database retrieval.

This is a simple model, but works well for small applications

SrRupert

This post has been edited by born2c0de: 23 March 2007 - 11:43 PM

Was This Post Helpful? 0
  • +
  • -

#6 cocacola  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 24-April 07

Re: visual basic login code

Posted 24 April 2007 - 08:58 PM

hi, im facing the same problem on user login validation.
im using visual studio 2005, asp.net to build my website, mysql as my database, Ms ODBC as my connector to the database. like rups, i have no idea how to compare the value input by user with the value stored in the database to validate if the username and password entered are valid.
Pls help..ive been stucked with this for weeks! if i dont solve this, i cant continue with the rests of my development.
Thank you.
Was This Post Helpful? 0
  • +
  • -

#7 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: visual basic login code

Posted 24 April 2007 - 11:15 PM

Do you know how to write SQL queries?

This will be a two step process. First execute an SQL query to retrieve the ID number(primary key) of the user using the username in the WHERE clause of the query. If a result is returned from the query you know it is a valid username. If not then prompt the user to reenter the username.

If the username is valid, then execute a second SQL query using the ID number(primary key) in the WHERE clause. Take the returned value from the query and compare it against the password entered by the user. If they match then allow the user to proceed.
Was This Post Helpful? 0
  • +
  • -

#8 cocacola  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 24-April 07

Re: visual basic login code

Posted 25 April 2007 - 02:24 PM

View Postjayman9, on 24 Apr, 2007 - 11:15 PM, said:

Do you know how to write SQL queries?

This will be a two step process. First execute an SQL query to retrieve the ID number(primary key) of the user using the username in the WHERE clause of the query. If a result is returned from the query you know it is a valid username. If not then prompt the user to reenter the username.

If the username is valid, then execute a second SQL query using the ID number(primary key) in the WHERE clause. Take the returned value from the query and compare it against the password entered by the user. If they match then allow the user to proceed.


I'm not really sure of how to write it as everything i wrote gave me error.
can you provide me with a sample code?

i tried this in my code and it gave me 22 errors. "syntax error, declaration expected, statement cannot appear outside of a method body".

Quote

<script runat="server">
protected Login1_Authenticated(Object sender, EventArgs e)
{

SqlConnection myConnection;
SqlCommand myCommand;
SqlDataReader myDataReader;

myConnection = new SqlConnection(ConfigurationSettings.AppSettings["slimConnectionString"]);
myConnection.Open();

//prepare sql statements
myCommand = new SqlCommand("SELECT Name, Password FROM MEMBER", myConnection);
myDataReader = myCommand.ExecuteReader();


while (myDataReader.Read())
{

if ((UserName == myDataReader["Name"].ToString()) & (Password == myDataReader["Password"].ToString()))
{
boolReturnValue = true;
}
else { boolReturnValue = false; }
return boolReturnValue;

}

//cleanup objects
myDataReader.Close();
myConnection.Close();

</script>


then i tried this, theres no error, but the it always displays "login failure" even if i keyed in the correct username and password.

Quote

<script runat="server">


Dim Username As String
Dim Password As String
Dim Message As String
Dim returnValue As Boolean


Public Sub Login1_onclick(ByVal sender As Object, ByVal args As EventArgs)

Username = Login1.UserName.ToString()
Password = Login1.Password.ToString()
If (Membership.ValidateUser(Login1.UserName, Login1.Password)) Then
FormsAuthentication.RedirectFromLoginPage(Username, True)
Else
Message = "Login failed. Please check your user name and password and try again."
End If

End Sub



</script>


Is there anything wrong with my code? missing any import libraries line or database connection or anything? as i din import any in my code and the code i placed here are almost exactly the complete code i have for my website, except for the textboxes and the buttons part.
and btw, i would like to have the user login using their ID number and password. how can i achieve that?

help needed urgently~
Thank you in advance
Was This Post Helpful? 0
  • +
  • -

#9 htu6ruyf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-March 10

Re: visual basic login code

Posted 08 March 2010 - 01:27 AM

View PostAmadeus, on 10 July 2006 - 05:28 PM, said:

Can you specify which database you'll be using? Deoending on the DB, the connection strings will be different, although the methodology for login validation is the same. Also, will you be storing the passwords in an encrypted format?

please can you help me on how to make code in log in using visual basic in inventory system?

hello?
Was This Post Helpful? 0
  • +
  • -

#10 Kinwang2009  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 76
  • Joined: 07-February 10

Re: visual basic login code

Posted 08 March 2010 - 02:43 AM

View Postrups, on 10 July 2006 - 04:40 PM, said:

i want to write a code for login form for validation.... i m creating login page where user can enter his name and password.i am using microsoft acess database.

how can i compaire the data which is enter by user and the data which is stored in database for validation.

can anybody give me some code...


Hi rups,

Here is my attached Help.

hope this helps.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#11 cHeToFuNk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-February 10

Re: visual basic login code

Posted 09 March 2010 - 06:46 PM

im new here .. and im searching for a free video tutorial on visual basic 2008, java and photoshop.. can anyone help me ..?????
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1