Click here to Skip to main content
15,901,737 members
Home / Discussions / C#
   

C#

 
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 
Answer== and .Equals() are different. Pin
Nagy Vilmos9-Jul-09 22:19
professionalNagy Vilmos9-Jul-09 22:19 
QuestionHow can I encrypt to message in WCF? Pin
dataminers9-Jul-09 20:40
dataminers9-Jul-09 20:40 
AnswerRe: How can I encrypt to message in WCF? Pin
SeMartens9-Jul-09 21:09
SeMartens9-Jul-09 21:09 
AnswerRe: How can I encrypt to message in WCF? Pin
SeMartens9-Jul-09 21:10
SeMartens9-Jul-09 21:10 
QuestionModified TextBox property not persisting in designer Pin
SillyPants9-Jul-09 19:51
SillyPants9-Jul-09 19:51 
AnswerRe: Modified TextBox property not persisting in designer Pin
DaveyM699-Jul-09 22:39
professionalDaveyM699-Jul-09 22:39 
QuestionOver Lay Image Pin
satsumatable9-Jul-09 19:27
satsumatable9-Jul-09 19:27 
AnswerRe: Over Lay Image Pin
dan!sh 9-Jul-09 19:31
professional dan!sh 9-Jul-09 19:31 

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.