[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Accessing Database - Login System C#

Posted on 2006-10-31
5
Medium Priority
?
942 Views
Last Modified: 2008-02-01
Hey guys,

I am trying to create a more secure login for my Windows App using Visual Studio 2005 C#.  I have a MS Access Database, which has the following collums:
UserName   Password

And these are the details inside:
username1  password1
username2 password2
username3 password3
etc

I have used a DataGridView to connect the database to the program, I am unsure if that's correct.  Anyway what I want to do is the user types their username, then password.  When they click Accept (button) then I want the program to check the database, see if the user name is correct with the right password, and then return whether it is correct or not.  

After that I think I should be able to handle the permissions side.  So can anybody help me out please?  I am not great with C# so will need it explain in idiot terms lol, with as much help with the code as possible.
0
Comment
Question by:angus_young_acdc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 200 total points
ID: 17857663
strSql = string.Format("SELECT LOGINPWD FROM BT_USERS WHERE LOGINID ="
                              +" {0}",
                              clsCommon.quotedStr(txt_loginid.Text));
                        System.Data.SqlClient.SqlConnection Connection = new SqlConnection("");
                        System.Data.SqlClient.SqlCommand Command= new SqlCommand
                              (strSql,Connection);
                        SqlDataReader sql_dat_rdrLogin = Command.ExecuteReader();
                        if(sql_dat_rdrLogin.HasRows)
                        {
                              sql_dat_rdrLogin.Read();
                              if (sql_dat_rdrLogin[0].ToString() == txt_pwd.Text.Trim())
                              {
                                    //login
                              }
                              else
                              {
                                    MessageBox.Show("Password incorrect");
                                    txt_pwd.Focus();
                              }
                        }
                        else
                        {
                              MessageBox.Show("Username incorrect");
                              txt_loginid.Focus();
                        }
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 17857672
//  new SqlConnection(""); instead of this

 new SqlConnection(urconnectionstring);
0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 17857678
and also after
System.Data.SqlClient.SqlConnection Connection = new SqlConnection("");
Connection.Open()
0
 
LVL 15

Author Comment

by:angus_young_acdc
ID: 17865048
Thanks gauthampj, I will try it shortly and let you know
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question