Click here to Skip to main content
15,916,378 members
Home / Discussions / C#
   

C#

 
GeneralRe: code to invoke querty keyboard keys in windows applicattion Pin
Vivek Vijayan10-Jul-09 3:08
Vivek Vijayan10-Jul-09 3:08 
GeneralRe: code to invoke querty keyboard keys in windows applicattion Pin
Mirko198010-Jul-09 3:16
Mirko198010-Jul-09 3:16 
GeneralRe: code to invoke querty keyboard keys in windows applicattion Pin
Vivek Vijayan10-Jul-09 21:04
Vivek Vijayan10-Jul-09 21:04 
GeneralRe: code to invoke querty keyboard keys in windows applicattion Pin
Mirko198013-Jul-09 0:15
Mirko198013-Jul-09 0:15 
QuestionAdobe Acrobat PDF link cann't work on windows form Pin
Bhim Prakash Singh9-Jul-09 22:48
Bhim Prakash Singh9-Jul-09 22:48 
AnswerRepost? Pin
Manas Bhardwaj9-Jul-09 22:51
professionalManas Bhardwaj9-Jul-09 22:51 
AnswerRe: Adobe Acrobat PDF link cann't work on windows form Pin
Vasudevan Deepak Kumar10-Jul-09 2:57
Vasudevan Deepak Kumar10-Jul-09 2:57 
Questionadobe acrobat pdf link cann't work on windows form Pin
Bhim Prakash Singh9-Jul-09 22:47
Bhim Prakash Singh9-Jul-09 22:47 
AnswerRe: adobe acrobat pdf link cann't work on windows form Pin
Manas Bhardwaj9-Jul-09 22:52
professionalManas Bhardwaj9-Jul-09 22:52 
QuestionVersion in VS2005 or VS2008 Pin
stancrm9-Jul-09 22:39
stancrm9-Jul-09 22:39 
AnswerRe: Version in VS2005 or VS2008 Pin
Manas Bhardwaj9-Jul-09 22:50
professionalManas Bhardwaj9-Jul-09 22:50 
QuestionI'm trying to build a TaskBar similar application, how to enum running applications? (Advanced Q) Pin
leeoze9-Jul-09 22:09
leeoze9-Jul-09 22:09 
Questionneed help Pin
mjawadkhatri9-Jul-09 21:12
mjawadkhatri9-Jul-09 21:12 
AnswerRe: need help Pin
SeMartens9-Jul-09 21:29
SeMartens9-Jul-09 21:29 
GeneralRe: need help Pin
mjawadkhatri9-Jul-09 21:42
mjawadkhatri9-Jul-09 21:42 
GeneralRe: need help Pin
SeMartens9-Jul-09 21:53
SeMartens9-Jul-09 21:53 
Okay, normally you should write it by yourself, but today is friday, so here it comes:

private bool DoesUserExists(string sUserID) {
   OdbcConnection cn;
   OdbcCommand cmd;
   OdbcParameter dbParameter;
   OdbcDataReader odr;

   string MyString = "Select * from users WHERE userid = @userid";

    cn = new OdbcConnection("Driver={Microsoft ODBC for Oracle};Server=orcl8i;UID=itehad;PWD=creative;");
    cn.Open();
    cmd = new OdbcCommand(MyString, cn);
    dbParameter = new OdbcParameter("userid", sUserID");
    cmd.Parameters.Add(dbParameter);
    odr = cmd.ExecuteReader();

    bool bResult = (odr.HasRows && odr.Read());
    odr.Close();
    cn.Close();
    return bResult;
}

private void login_Click(object sender, EventArgs e)
{
   if(this.DoesUserExists(usr.Text)) {
     MessageBox.Show("User Login", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
   } else {
       DialogResult drsave = MessageBox.Show("Login Fail", "Erorr", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
       if (drsave == DialogResult.OK)
       {
          usr.Text = "";
          pass.Text = "";
          usr.Focus();
        } else {
            this.Close();
        }
   }
}


You should add fail-safe to your app by using try-catch blocks, especially while interacting with the database. Next step would be to seperate the dataccess into an own assembly.

Regards
Sebastian

It's not a bug, it's a feature!

Check out my CodeProject article Permission-by-aspect.

Me in Softwareland.

GeneralRe: need help Pin
mjawadkhatri10-Jul-09 0:17
mjawadkhatri10-Jul-09 0:17 
GeneralRe: need help Pin
SeMartens10-Jul-09 0:29
SeMartens10-Jul-09 0:29 
GeneralRe: need help Pin
mjawadkhatri10-Jul-09 0:40
mjawadkhatri10-Jul-09 0:40 
GeneralRe: need help Pin
SeMartens10-Jul-09 0:45
SeMartens10-Jul-09 0:45 
GeneralRe: need help Pin
mjawadkhatri10-Jul-09 0:50
mjawadkhatri10-Jul-09 0:50 
GeneralRe: need help Pin
N a v a n e e t h9-Jul-09 21:46
N a v a n e e t h9-Jul-09 21:46 
JokeRe: need help Pin
SeMartens9-Jul-09 21:55
SeMartens9-Jul-09 21:55 
GeneralRe: need help Pin
mjawadkhatri10-Jul-09 0:29
mjawadkhatri10-Jul-09 0:29 
AnswerRe: need help Pin
K03069-Jul-09 21:39
K03069-Jul-09 21:39 

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.