473,325 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Display Data from Local VB Database in a label after clicking a buttong

I have created a simple log on screen that checks the local database if the username and password exist and to add them to the database if it doesn't exist.

On the Login window I have a Label that I would like to equal the user who has logged on.


Here is my code.....



Expand|Select|Wrap|Line Numbers
  1. Public Class loginWindow
  2.  
  3.     Private Users As New UsersDataSetTableAdapters.CredentialsTableAdapter
  4.     Private DataSet As New UsersDataSet
  5.  
  6.     Private Sub Register(ByVal Username As String, ByVal Password As String)
  7.         Dim Row As UsersDataSet.CredentialsRow = DataSet.Credentials.FindByUsername(Username)
  8.         If Row Is Nothing Then
  9.             DataSet.Credentials.AddCredentialsRow(Username, Password)
  10.             Users.Update(DataSet)
  11.             MessageBox.Show("Account Created")
  12.         Else
  13.             MessageBox.Show("Username not available please choose another!")
  14.         End If
  15.  
  16.  
  17.     End Sub
  18.     Private Sub Login(ByVal Username As String, ByVal Password As String)
  19.         Dim Row As UsersDataSet.CredentialsRow = DataSet.Credentials.FindByUsername(Username)
  20.         If Not Row Is Nothing AndAlso Row.Password = Password Then
  21.             MessageBox.Show("Correct Credentials Logging in!")
  22.         Else
  23.             MessageBox.Show("Invalid Credentials")
  24.         End If
  25.     End Sub
  26.     Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  27.  
  28.         Users.Fill(DataSet.Credentials())
  29.     End Sub
  30.  
  31.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles LoginButton.Click
  32.  
  33.         Label1.Text = 
  34.  
  35.  
  36.         Call Login(UsernameTextBox.Text, LoginTextBox.Text)
  37.  
  38.     End Sub
  39.  
  40.     Private Sub RegistrationButton_Click(sender As System.Object, e As System.EventArgs) Handles RegistrationButton.Click
  41.         Call Register(UsernameTextBox.Text, LoginTextBox.Text)
  42.     End Sub
  43.  
  44.     Private Sub LoginTextBox_Click(sender As Object, e As System.EventArgs) Handles LoginTextBox.Click
  45.         LoginTextBox.Text = ""
  46.     End Sub
  47.  
  48.     Private Sub UsernameTextBox_Click(sender As Object, e As System.EventArgs) Handles UsernameTextBox.Click
  49.         UsernameTextBox.Text = ""
  50.     End Sub
  51.  
  52. End Class
Jun 20 '12 #1
0 1404

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ray in HK | last post by:
What are the differences between LOAD DATA INFILE and LOAD DATA LOCAL INFILE ? I found some web hosting company do not allow using LOAD DATA INFILE but allow LOAD DATA LOCAL INFILE. The reason...
9
by: Mike Preston | last post by:
IE 6.0 (not interested in other browsers at the moment) I have looked everywhere I can find to look and googled until I am cross-eyed and am hoping somebody knows what I'm doing wrong. I have...
1
by: mhnazly | last post by:
i'm trying to read data from SQL Server database using data reader and assigned it to a label in my asp.net web application. but when the button is clicked, nothing appears. please help, thanks. ...
2
by: Santosh | last post by:
Dear all i want to bind data to datagrid header template i am wrtting follwing code it is displaying data with in item template not but it is display data in header template <asp:DataGrid...
8
by: mouac01 | last post by:
I'm not sure if this is possible. I would like to have a PHP app on the Internet connect and write to a local database (Intranet). For example, users would go to a web site...
6
by: geeteshss | last post by:
hi all, i am using C#.NET(.NET 2003 version 1.1) with oracle as database (TOAD is the software for the database). I am a beginner so i was trying to display my data in the database screen...
7
by: nma | last post by:
Hi I'm trying to display data in a table list format but error message like this appear. What is wrong with the code? "Parse error: syntax error, unexpected '<' in C:\htdocs\...\MB2movieinfo.php...
3
by: Elavarasi | last post by:
My database (ms access) is in ftp; i want to transfer the one particular table content to local db which is in my system... the coding i written was ' for local database connection...
1
by: ganesh22 | last post by:
Hi, my requriment is i want to display data from database in ms.word? Iam using asp.net with C# bcoz iam inserting resume in sqlserver, so i want to display that resume in word
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.