Click here to Skip to main content
15,894,410 members
Home / Discussions / C#
   

C#

 
GeneralRe: database connection error with sa user in SQL Express 2005 Pin
Chesnokov Yuriy15-Apr-10 0:55
professionalChesnokov Yuriy15-Apr-10 0:55 
GeneralRe: database connection error with sa user in SQL Express 2005 Pin
Stanciu Vlad15-Apr-10 1:04
Stanciu Vlad15-Apr-10 1:04 
Questiondatagridview Pin
ali_reza_zareian14-Apr-10 20:02
ali_reza_zareian14-Apr-10 20:02 
AnswerRe: datagridview Pin
thatraja14-Apr-10 20:14
professionalthatraja14-Apr-10 20:14 
AnswerRe: datagridview Pin
Not Active14-Apr-10 20:16
mentorNot Active14-Apr-10 20:16 
Questionhow to bind data to datagridview which has combobox and checkbox columns Pin
NarVish14-Apr-10 19:24
NarVish14-Apr-10 19:24 
AnswerRe: how to bind data to datagridview which has combobox and checkbox columns Pin
Abhinav S14-Apr-10 19:36
Abhinav S14-Apr-10 19:36 
QuestionHTTPWebRequest to Increase Processing Speed Pin
Johndas14-Apr-10 19:07
Johndas14-Apr-10 19:07 
AnswerRe: HTTPWebRequest to Increase Processing Speed Pin
Not Active14-Apr-10 20:49
mentorNot Active14-Apr-10 20:49 
QuestionHow to set colour column in datagridview Pin
NarVish14-Apr-10 18:09
NarVish14-Apr-10 18:09 
AnswerRe: How to set colour column in datagridview Pin
ali_reza_zareian14-Apr-10 20:07
ali_reza_zareian14-Apr-10 20:07 
QuestionReturn type error Pin
mprice21414-Apr-10 17:28
mprice21414-Apr-10 17:28 
AnswerRe: Return type error Pin
ali_reza_zareian14-Apr-10 20:14
ali_reza_zareian14-Apr-10 20:14 
GeneralRe: Return type error Pin
mprice21415-Apr-10 3:02
mprice21415-Apr-10 3:02 
QuestionMimic Active Directory browser... Pin
Jacob Dixon14-Apr-10 14:48
Jacob Dixon14-Apr-10 14:48 
QuestionEntity Framework and 'char' type mapping Pin
student_rhr14-Apr-10 10:21
student_rhr14-Apr-10 10:21 
QuestionWindows Service - Service Automatically stops when error is thrown Pin
Joe Brislin14-Apr-10 9:13
Joe Brislin14-Apr-10 9:13 
AnswerRe: Windows Service - Service Automatically stops when error is thrown Pin
PIEBALDconsult14-Apr-10 11:06
mvePIEBALDconsult14-Apr-10 11:06 
GeneralRe: Windows Service - Service Automatically stops when error is thrown Pin
Joe Brislin14-Apr-10 11:44
Joe Brislin14-Apr-10 11:44 
AnswerRe: Windows Service - Service Automatically stops when error is thrown Pin
Michel Godfroid14-Apr-10 12:56
Michel Godfroid14-Apr-10 12:56 
GeneralRe: Windows Service - Service Automatically stops when error is thrown Pin
PIEBALDconsult14-Apr-10 13:03
mvePIEBALDconsult14-Apr-10 13:03 
GeneralRe: Windows Service - Service Automatically stops when error is thrown Pin
Michel Godfroid14-Apr-10 13:10
Michel Godfroid14-Apr-10 13:10 
GeneralRe: Windows Service - Service Automatically stops when error is thrown Pin
Joe Brislin15-Apr-10 4:16
Joe Brislin15-Apr-10 4:16 
GeneralRe: Windows Service - Service Automatically stops when error is thrown Pin
PIEBALDconsult15-Apr-10 4:58
mvePIEBALDconsult15-Apr-10 4:58 
QuestionHelp with a Log-in Screen Pin
Geodude48714-Apr-10 7:24
Geodude48714-Apr-10 7:24 
Hey everybody, if somebody can help me with this I'd really appreciate it. I'm currently writing a Ticketmaster esque program, in which we have to have a user log-in and out of the program. Well I have a main form, and a log-in form. The user clicks a linked label on the main form to load up the log-in form. Sign in with their credentials and click the log-in button on the log-in form. I have it reading from and checking an access database file to make sure that they have log-in information and that it is correct. What I need now is to be able to pass the [username] from the database that they use on the login form back to the main form, so that the program can recognize if an administrator logs in. Here is my main form code for the log-in button:
private void lnklblLogIn_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
    sp.Stop();
    frmLogIn LogIn = new frmLogIn();
    LogIn.Show();                     
}

and here is my log-in form code for the log-in button:
private void btnLogIn_Click(object sender, EventArgs e)
        {
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\John\\Desktop\\Database1.mdb");
            OleDbCommand com = new OleDbCommand("SELECT UserName, PassWord FROM Table1",con);
            OleDbDataReader reader;
            
            bool permit = false;

            try
            {
                con.Open();
                reader = com.ExecuteReader();
                while (reader.Read())
                {
                    if (txtUserName.Text == (reader["UserName"].ToString()) && mtxtPassWord.Text == reader["PassWord"].ToString())
                    {
                        permit = true;
                        break;
                    }
                }

                con.Close();
            }
            catch
            {
                MessageBox.Show("File not able to be read");
                return;
            }

            if (permit != true)
                MessageBox.Show("Username or Password are not correct.");
            else
            {
                Close();
            }
                
        }

So again my issue is being able to get the username logged in with on the "Log-in" form back to the main form so the main form knows who has logged in. If somebody can help me with this I'd really appreciate it

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.