How to create simple c++ database on visual studio ?

Hello
I wanted to make a simple database of Name , ID etc.
please I want full illustration from A to Z
REGARDS
Any more details than that?
•Write a C++ program that stores the data of employees working in a company. The employees’ data include: ID, name, address, rank, hours worked, and overtime hours.
System Functions :
•Add a new employee.
•Edit the data of stored employees.
•Calculate the payment of stored employees.
•Search for a certain employee and display his/her data.
•Calculate the average payment for all employees.

That's what I wanna do store it and then recall it easily and edit it
Last edited on
Check this out ..

w.codeproject.com/Articles/22711/Using-Database-in-your-MFC-program-A-beginner-s-ex
Please can u re-write the URL
cuz this page does not exist
http://www.codeproject.com/script/Articles/Using-Database-in-your-MFC-program-A-beginner-s-ex

and this site says http://www.codeproject.com/Articles/Using-Database-in-your-MFC-program-A-beginner-s-ex
The member requested was not found.
.....what I can I do ?
Last edited on
Show a least a LITTLE effort man. Google "visual c++ database tutorial" and you will find dozens of tutorial, videos, examples, etc. Then, post back at a forum like this with SPECIFIC questions if you get stuck.
thx
closed account (3qX21hU5)
1
2
3
4
5
6
7
•Write a C++ program that stores the data of employees working in a company. The employees’ data include: ID, name, address, rank, hours worked, and overtime hours. 
System Functions :
•Add a new employee. 
•Edit the data of stored employees. 
•Calculate the payment of stored employees. 
•Search for a certain employee and display his/her data. 
•Calculate the average payment for all employees. 


From that it seems like your teacher wants you to write a program that acts like a timesheet program for a workplace. This is a pretty complicated program so I am assume you are familiar with classes and most of the basics of C++.

So like cnoeval said do some research on how to go about it, and then come back with some code of yours and we will help guide you in the right direction.

ok what's wrong here :
the seachname function is not working !!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void input () ;
void searchname () ;
int main ()
{
	system ("title simple data base !") ;
	system ("CLS");
	int choice ;
	system ("color 0F");
	cout << "Press 1 : to Input a new data" << endl;
	cout << "Press 2 : for Searching by name" << endl;
	cout << "Press 3 : to Exit" << endl;
	cin >> choice ;
	
	if (choice == 1)
	{
		input () ;
	}

	else if (choice == 2)
	{
	    searchname () ;
	}
}

void input () 
{
	string name ;
	int ID , salary ;
	ofstream worker ("worker.text",ios ::app) ;
	cout << "Please Enter your name : " ;
	cin >> name ;
	cout << "Please Enter your ID : " ;
	cin >> ID ;
	cout << "Please Enter your salary : " ;
	cin >> salary ;

	worker << name << ' ' << ID << ' ' << salary << endl;
	worker.close () ;
	cout << endl;
	main () ;
}


void searchname () 
{
	system ("cls") ;
	string name , str ;
	int salary , ID ;
	ifstream worker ("worker.txt") ;
	cout << "Enter the Name : " ;
	cin >> str ;
	while (worker >> name >> ID >> salary)
	{
		if (str == name)
		{
			system ("cls") ;
			cout << "The Worker has been found !" << endl;
			cout << "Name" << ' ' << "ID" << ' ' << "Salary"<< endl;
			cout << "---------------" << endl;
			cout << name << ' ' << ID << ' ' << salary << endl;
		}

		else if (!(str == name))
		{
			system ("cls");
			cout << "Not found !"<< endl;
		}
	}
	system ("Pause") ;
	cin.get () ;
	main () ;
}
Last edited on
Maybe it's just me, but what does while (worker >> name >> ID >> salary) mean?

I think that might be your problem...

Yeah, it's just me :D Sorry..
Last edited on
it means go to the worker text and memorize the values of name and ID and Salary and then if str == name , cout the corresponding ID Salary
and Thanks any way
WOWOWO!!!
hang on a minute.....I've created another prototype and It works !!
here it is :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# include <iostream>
# include <string >
# include <fstream>
using namespace std ;
void name () ;
void ID () ;
int main ()
{
	system ("cls") ;
	system ("color 0F") ;
	int ch1 ;
	cout << "1 for new data" << endl;
	cout << "2 for seaching by ID" << endl;
        cin >> ch1 ;
	if (ch1 == 1)
	{
		name () ;
	}
	else if (ch1 == 2)
	{
		ID () ;
	}

}

void name ()
{
	system ("cls") ;
	string name ;
	ofstream worker ("eslam.txt",ios ::app);
	int ID , salary ;
	cout << "Name : ";
	cin >> name ;
	cout << "ID : " ;
	cin >> ID ;
	cout << "Salary : " ;
	cin >> salary ;

	worker << name << " " << ID << " " << salary << endl;
	worker.close () ;
	cin.get () ;
	main () ;
}

void ID ()
{
	ifstream worker ("eslam.txt") ;
	int ID , salary , str ;
	string name  ;
	cout << "Enter ID : " ;
	cin >> str ;

	while (worker >> name >> ID >> salary)
	{
		if (str == ID)
		{
			system ("cls") ;
			cout << "Data found !" << endl;
			cout << name << " " << ID << " "  << salary << endl; 
		}

		else if (!(str == ID))
		{
			system ("cls") ;
			cout << "Not Found !" << endl;
		}
	}

	system ("pause") ;
	main () ;
}


but why the main one not working
Last edited on
Topic archived. No new replies allowed.