- Create a "Windows Forms Application" project
- Add a new form. By default, it will have a name of "Form2"
- Add 2 labels, 2 textboxes, and 2 buttons like the one shown below:
- open the first form (Form1) and double click on the empty space. This should show the Form1_Load event. Declare an instance of Form2 and display it. (Use ShowDialog instead of Show).
- Open the second form (Form2) and view the properties of the second textfield (password text box). Specify * in the PasswordChar attribute.
Double click on the Login button. This will show the button1_click event. Put all necessary checking here like the one shown.
**You can change the checking part to comparing the values with your database. For example:OleDbConnection cn = new OleDbConnection("YourConnectionString");
cn.Open();
DataTable dt = new DataTable();
OleDbCommand cmd = new OleDbCommand("select * from usertable where username='"+textBox1.Text+"' and password='" + textBox2.Text+"'",cn);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(dt);
if(dt.Rows.Count>0){
MessageBox.Show("Welcome!");
}
else{
MessageBox.Show("Incorrect Username or Password");
}
- Go back to the form view of Form2 and double click on the Cancel button. The cancel button should close the application.
- Open Form2 again and view its properties and change the Startup Position attribute
C# express doesn't include a report designer or viewer. Reports however, is very much needed when creating a business software. Since C# express doesn't include a report designer, we need to find other means. One is to use a free report such as MyNeoReport. This however may not work under many circumstances. The other alternative would be to use a proven report engine and designer-Crystal Report. Crystal Report has been used by many developers (in our city). However, using a free programming language and IDE, and a free database is very limiting. Not much information can be gathered on the net either (with regards to reporting as of this writing). Here's a way to use Crystal Reports using Firebird database and C# Express as software development IDE: Pre-requisites: C# Express 2005 EMS SQL Manager 2005 for InterBase & Firebird Lite Crystal Reports 10 Create the following database: Name: TestDB1 Tables: TESTTABLE1 Columns: ID - PK, INTEGER,AUTOINCREMENT DES...
Comments