10 Replies - 571 Views - Last Post: 14 July 2010 - 12:14 PM Rate Topic: -----

#1 D.Mulroy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 430
  • Joined: 30-June 10

Simple log in feature

Posted 14 July 2010 - 11:01 AM

I am no pro at programming, only coming from a vb6 background. I am trying to expand and learn C# and have chosen to start by programming an application that is a more fun version of a "mad minute" for my mothers first grade class. She would like me to have a log on for each of her students. How can I accomplish this? Could I use a database that has the students login and their password then have the program check them agains eachother, or could I use two arrays somehow to do the same. I read that there is some sort of database that comes with Visual C# 2010 express edition. Note that I have never worked with arrays or databases so if someone could post a link to information that would be extremely helpful :]

Please do not post any code! I want to figure this out on my own :]

Is This A Good Question/Topic? 0
  • +

Replies To: Simple log in feature

#2 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Simple log in feature

Posted 14 July 2010 - 11:23 AM

In order to have a working robust login system you're going to have to have some sort of data persistence. I'd recommend using an XML file to save information.

Since you say this is for a classrooms students you don't really need something big like a relational database. Just a simple XML file would suffice.

Read a bit about what XML is and what it's used for, then read up on the XDocument class to get a feel for it. Then post your questions on how to use it here if you have any.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8924
  • View blog
  • Posts: 33,447
  • Joined: 12-June 08

Re: Simple log in feature

Posted 14 July 2010 - 11:24 AM

Yes.. MSSQL Express is a decent database to use.. that's free as well.

You would essentially have a table structured by some unique key.. their name.. and their log in. Probably give them a default log in like their last name with a number. Have them change if it they want.

Then the program would save the information in another table using the unique key as a foreign key for that table.. build a nice way of viewing the information and time inserted and you are off and running.
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,651
  • Joined: 02-June 10

Re: Simple log in feature

Posted 14 July 2010 - 11:30 AM

Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5
is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.
Was This Post Helpful? 0
  • +
  • -

#5 D.Mulroy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 430
  • Joined: 30-June 10

Re: Simple log in feature

Posted 14 July 2010 - 11:30 AM

Okay I'll look into using XML as you suggest but I have decided to stick to learning basics first as I am already at a stand still. I chose to just use a If Statement to check for only my moms log in and password and I don't understand why its not working.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class logOn : Form
    {
        public logOn()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (txtUser.Text = "LMulroy") & (txtPass.Text="password")
            {
                //Here it will close this form and open another
            }
        }
    }
}



Why is
 txtUser.Text = "Lmulroy")
getting underlined in red?

This post has been edited by D.Mulroy: 14 July 2010 - 11:33 AM

Was This Post Helpful? 0
  • +
  • -

#6 demausdauth  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 636
  • Joined: 03-February 10

Re: Simple log in feature

Posted 14 July 2010 - 11:34 AM

You could use: a text file, xml file, database, etc...
My choice for free powerful database.

http://www.dreaminco..._1&#entry302740

I quite agree an xml file would be a great starter data source.

Here's where you can start with xml
Was This Post Helpful? 0
  • +
  • -

#7 demausdauth  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 636
  • Joined: 03-February 10

Re: Simple log in feature

Posted 14 July 2010 - 11:39 AM

In VB6 and VB.Net '=' is the assign operator and compare operator, whereas in C# '=' is the assign operator and '==' is the compare operator.


VB.Net
Dim newValue As String = "Neat"
If newValue = "Neat" Then 
    'do something
End If

C#.Net
String newValue = "Neat";
if(newValue == "Neat")
{
  //do something
}



Was This Post Helpful? 0
  • +
  • -

#8 D.Mulroy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 430
  • Joined: 30-June 10

Re: Simple log in feature

Posted 14 July 2010 - 12:02 PM

Okay thanks for your help. I think instead of just trying to pick C# up off just playing around with it i'm going to order a copy of Head First C# to learn. Is this book a good choice? http://books.google....epage&q&f=false
Was This Post Helpful? 0
  • +
  • -

#9 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Simple log in feature

Posted 14 July 2010 - 12:09 PM

Well, I think it's a very good idea to pick up a book. Head First C# is pretty neat and will get you pumped because you'll be building actual programs with it.

As for your immediate error with the IF statement, you are missing some parenthesis.

WRONG

if (txtUser.Text = "LMulroy") & (txtPass.Text="password")
{
    //Here it will close this form and open another
}


CORRECT

if ((txtUser.Text = "LMulroy") & (txtPass.Text="password"))
{
    //Here it will close this form and open another
}



It also goes without saying that you shouldn't hard code credentials in your application, but you're probably doing it this way just to test things out.

This post has been edited by stapia.gutierrez: 14 July 2010 - 12:10 PM

Was This Post Helpful? 0
  • +
  • -

#10 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,651
  • Joined: 02-June 10

Re: Simple log in feature

Posted 14 July 2010 - 12:10 PM

View PostD.Mulroy, on 14 July 2010 - 11:02 AM, said:

Okay thanks for your help. I think instead of just trying to pick C# up off just playing around with it i'm going to order a copy of Head First C# to learn. Is this book a good choice? http://books.google....epage&q&f=false


I own it. Its one of many "self teaching" books I have. Its good, though I would have liked it if they printed it in color. Lots of arrows and notations explaining each part of a line of code as if you are looking at a teacher using a chalkboard.

Since you are going to be paying for shipping and $50 for this book, I would say toss in another $19 on the other book I mentioned. It's really good about cutting right to the chase and learning through actually building useful applications.
Was This Post Helpful? 0
  • +
  • -

#11 D.Mulroy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 430
  • Joined: 30-June 10

Re: Simple log in feature

Posted 14 July 2010 - 12:14 PM

Okay well i'll probably be around here in a few weeks again after I get started with them thanks for everyones help and deeply sorry about the quad post :/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1