473,549 Members | 2,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I do this?

Ajay Bhalala
119 New Member
I have created the login form in vb.net

In this form there are 2 labels : Username & Password
and 2 Text-boxes for enter the username and password and 1 button "Login"

I have created the ms access database named "Project.md b" and in this database, I have created 1 table named "UserAccoun t" and it's fields are "ID", "UserName" & "Password"

I have write the code as following...
Expand|Select|Wrap|Line Numbers
  1. Imports System.Data.OleDb
  2.  
  3. Public Class Login
  4.  
  5.     Public con As New OleDbConnection("Provider=microsoft.jet.oledb.4.0 ; Data Source=E:\Brinda & Jay\Brinda\02 S.Y\VB.NET\My Project\Project.mdb")
  6.     Public qry As String
  7.     Public dr As OleDbDataReader
  8.  
  9. Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  10.         con.Open()
  11.         qry = "select * from UserAccount where UserName like ' " & TextBox1.Text & " ' and Password like ' " & TextBox2.Text & " ' "
  12.         Dim cmd As New OleDbCommand(qry, con)
  13.         cmd.CommandText = qry
  14.         cmd.Connection = con
  15.         dr = cmd.ExecuteReader
  16.         If dr.Read = True Then
  17.             MsgBox("Accessed")
  18.         Else
  19.             MsgBox("Not Accessed")
  20.         End If
  21.         con.Close()
  22.     End Sub
  23. End Class
  24.  
there is no error in this code, but when I run this form and though I enter the right username and password but "Not Accessed" msgbox is displays. I can't understand What changes I have to do in this code?

Which changes I have to do in this code? Please help.
Nov 17 '14 #1
3 1271
Rabbit
12,516 Recognized Expert Moderator MVP
Output the query that it's actually running. You put in extra spaces before and after the username and password.
Nov 17 '14 #2
Frinavale
9,735 Recognized Expert Moderator Expert
Use the OleDbDataReader .HasRows Property instead of OleDbDataReader .Read Method.

Please also read the documentation about using OleDbCommand.Pa rameters because it will avoid any SQL insertion attacks.

-Frinny
Nov 17 '14 #3
Ajay Bhalala
119 New Member
Thank you so much for the help to both Rabbit and Frinavale. I will try it. Ok
Nov 18 '14 #4

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

Similar topics

4
3336
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company Order By Company ASC";
5
2741
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to $location_other I keep getting "Notice: Undefined index: location_other" referring to (!($_POST)) { $location_other = $location; } else
2
2716
by: Nick | last post by:
Can someone please tell me how to access elements from a multiple selection list? From what ive read on other posts, this is correct. I keep getting an "Undefined variable" error though... Form page************************************************************ <form action="/process.php" method="get" name="formOne" id="formOne"> <select...
2
2531
by: Alexander Ross | last post by:
I have a variable ($x) that can have 50 different (string) values. I want to check for 7 of those values and do something based on it ... as I see it I have 2 options: 1) if (($x=="one") || ($x=="two") || ... || ($x=="seven")) ... or 2) switch ($x){ case("one"):
0
3264
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records each!!!) Dan ==================== <style> body, table, tr, td { font-family: 'verdana'; font-size: 12px;
5
3201
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
5
10041
by: christopher vogt | last post by:
Hi, i'm wondering if there is something like $this-> to call a method inside another method of the same class without using the classname in front. I actually use class TEST { function func1()
6
2655
by: Phil Powell | last post by:
Ok guys, here we go again! SELECT s.nnet_produkt_storrelse_navn FROM nnet_produkt_storrelse s, nnet_produkt_varegruppe v, nnet_storrelse_varegruppe_assoc sv, nnet_produkt p WHERE s.nnet_produkt_storrelse.id = sv.nnet_produkt_storrelse_id AND sv.nnet_produkt_varegruppe_id = v.nnet_produkt_varegruppe_id AND sv.nnet_produkt_varegruppe_id IN (...
1
2185
by: Michel | last post by:
a site like this http://www.dvdzone2.com/dvd Can you make it in PHP and MySQL within 6 weeks? If so, send me your price 2 a r a (at) p a n d o r a . b e
11
3143
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in /home/krecik/public_html/silnik.php on line 251 Line 208: print ( "error: " . mysql_error()); Line 251: session_register("uprawnienia", "zalogowany"); I can...
0
7551
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5396
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5118
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1971
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1084
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.