Hello,
Sorry if my english is not so good...
I have to do a project called Library, with 3 forms
Form1 is the start form, it has 2 buttons"Register" and "Log in",3 textboxes for the FirstName,LastName,Password of the user(It usses your personal name not some nickname or else).
Press "Register" pop's up Form2.
Form2 is to enter your FirsName,LastName,Adress,School/HighSchool,Grade,Password in text boxes, and 2 buttons "Back" to go back to form1,"Register" to enter the data from text boxe into access table Useri.mdb ,pop's up a messagebox to say that you are registered and it goes back to form1.
The register part i did it...after a hard time searching the web.
In Form1 when you enter data in textboxes and press LOG IN it goes to Form3 but I don't know how to write the code to search in a access table.
I found some sample code's but it's not i'm lookin' for.
private void button2_Click(object sender, EventArgs e){string searchFor="Kan";int results=0;DataRow[] retunedRows;returnedRows=ds1.Tables["Useri"].Select("LastName='")+searchFor + "'");results = returnedRows.Lenght;if(result >0){DataRow dr1;dr1=returnedRows[0];the code to open FORM3;}else{MessageBox.Show("You ar not REGISTERED!!!");}}
And in form3 i have to do the same code to find book's but in addition i have to display the results in a textbox
The code to enter new records from Form2 is this:
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;using System.IO;using System.Net.Sockets;using System.Data.OleDb;namespace Atestat{ public partial class Form3 : Form { public Form3() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { System.Data.OleDb.OleDbCommandBuilder cb; cb = new System.Data.OleDb.OleDbCommandBuilder(da); DataRow dRow = ds1.Tables["Utilizatori"].NewRow(); dRow[0] = textBox1.Text; dRow[1] = textBox2.Text; dRow[2] = textBox3.Text; dRow[4] = comboBox2.Text; dRow[5] = textBox4.Text; dRow[3] = comboBox1.Text; ds1.Tables["Utilizatori"].Rows.Add(dRow); MaxRows = MaxRows + 1; inc = MaxRows - 1; da.Update(ds1, "Utilizatori"); MessageBox.Show("Ati fost autentificat cu succes!!!\nApasati OK si va puteti autentifica. "); this.Close(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } System.Data.OleDb.OleDbConnection con; DataSet ds1; System.Data.OleDb.OleDbDataAdapter da; int MaxRows = 0; int inc = 0; private void Form3_Load(object sender, EventArgs e) { con = new System.Data.OleDb.OleDbConnection(); ds1 = new DataSet(); con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\Atestat\\Utilizatori.mdb"; string sql = "SELECT * From Utilizatori"; da = new System.Data.OleDb.OleDbDataAdapter(sql, con); con.Open(); da.Fill(ds1, "Utilizatori"); NavigateRecords(); con.Close(); } private void NavigateRecords() { DataRow dRow = ds1.Tables["Utilizatori"].Rows[0]; textBox1.Text = dRow.ItemArray.GetValue(0).ToString(); textBox2.Text = dRow.ItemArray.GetValue(1).ToString(); textBox3.Text = dRow.ItemArray.GetValue(2).ToString(); comboBox1.Text = dRow.ItemArray.GetValue(5).ToString(); comboBox2.Text = dRow.ItemArray.GetValue(4).ToString(); textBox4.Text = dRow.ItemArray.GetValue(3).ToString(); textBox5.Text = dRow.ItemArray.GetValue(3).ToString(); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); comboBox1.Text = ""; comboBox2.Text = ""; } } }