C++ :: Employee Database - Bizarre Error With If Statement
Dec 21, 2014
I have written a program that stores employees in a database object. You can Add, hire, fire, promote, demote, and display employees. The program uses an interface, a database class, and an employee class with member functions.
The strange behavior is in my switch statement in interface.cpp. I have a '#' that represents a command line. Add and Display functions are ok, but if I hire, fire, promote or demote. It will display '##' for the next input. I ran the debugger and after hire/fire/promote/demote is called, the first if-statement goes to 'else' and I'm trying to figure out why.
I'm working on a program to store student's names, ID, and GPA, but for some reason the first and last name of the student are copied into every name of the database array once I scan them, regardless of whether or not add_student even runs.
typedef struct{ char *f_name; char *l_name; int stud_id; double gpa; } student_t; int add_student(student_t db[], char fname[], char lname[], int iden, double grade, int db_size){ int i, error;
[Code] ....
For example, if I type "a Adam Johnson 1234 4.00" it'll add the first student with name Adam Johnson. However, if I try to add another student named "Kyle Walker", it overwrites "Adam Johnson" with "Kyle Walker" as soon as the names are scanned.
I am trying to add some data to my SQL database using EntityFramework as so:
[HttpPost] public ActionResult Add(string moduleCode) { HttpCookie cookie = Request.Cookies["UserLogin"];
[Code]....
When ever it gets to the stage of db.SaveChanges() I get this error, but using intellisense I have checked the values in the object and there are no Null fields.
Do you think It might be better to use SQLConnection instead? Also I beleive EntityFramework is more secure becuase there is no SQL Injection, is this correct? So If I do go down the SQLConnection route could this SQL Injection pose a threat?
I'm trying to make a simple C++ program in which the user must try to guess a number, if they guess too high it says "too high" and if they guess too low it says "too low".
I also decided to add a feature which allows them to select how many tries they would like to guess the number. I tried to make "tries" type an enum so if the user could not pick an invalid number but for some reason i cannot use it in an if statement.
here is the code and i am getting the first error on line 27:
Code: #include <iostream> #include <ctime> #include <cstdlib> using namespace std; int guess;
Code: /* Demonstrates using the gets() return value. */ #include <stdio.h> /* Declare a character array to hold input, and a pointer. */ char input[257], *ptr;
[Code]....
I just got this from the book that I am using and it is for testing for input of a blank line and readers are being warned in using this format (line 18):
Code: while ( (*ptr = gets(input)) != NULL)
What is the correct syntax if a gcc compiler is to be used?
I have a question related to switch statement, which the switch in class employee2 gives me error at output. Program compiled well. I am using Code::Block Compiler V10.5. I have created object of class employee2 in main() function to get data from user, store it and display it. At the output, Compiler doesn't show actual output what i am expecting. The fun thing is my compiler printed emocion like (), where (hourly/monthly/weekly) was supposed to print.
Code: #include <iostream> using namespace std; enum period {hourly,weekly,monthly}; class employee2 { private : char ch; period x; double compensation;
I was created winform application with sql data base, after i created it i was converted to the installer file,for the other users but when they run the application did not connect to the database, how i fix this stuff...?
I am receiving error: "unable to open database file" using sqlite3_open function. I am using sqlite3.c (included amalgamation files). It happens only during ARM compiling/run. If I do the same at x86 compile/run everything works fine...
if (comboBox1.Enabled == true && textBox5.Text != "") { OleDbConnection con = new OleDbConnection(); con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" + @"Data Source= c:usersmert" + @"documentsvisual studio 2010ProjectsPayrollCSWindowsFormsApplication7P ayrollDB.accdb";
[Code]....
this is my code. I am getting this error on "cmdole2" query.
error text is:
---------------------------
--------------------------- System.Data.OleDb.OleDbException (0x80040E14): Syntax error in INSERT INTO statement. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(OleDbHResult hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult)
I've encountered a slight logical error in my code
/* Lab06_pensionplans.cpp Purpose : - Create a simple financial application to calculate retirement plans */ #include <iostream> #include <cstdlib> using namespace std; void displayMenu() { system("cls");
[Code] ....
Look at case 2, which the user supposed to key in a new input, the problem is the value will never got into main function, I don't know what should I modify with the function.
I can't seem to figure out whats causing this error: statement cannot resolve address of overloaded function . Error is before line 14 in bubblesortrand function. Thnx in advance.
void bubblesort(int num[], int a_size) { int i, j, temp; for(i = (a_size - 1); i >= 0; i--)
Afterwards I'm using this as a check throughout my application:
if (dbCount > 0) { // do something }
When I execute this code I'm getting the following error: "Operator '>' cannot be applied to operands of type 'method group' and 'int'"
So I'm guessing it has something to do with the cast of the dbCount-object but I don't understand why as I already stated that the count-object to be an Int32.
I am creating a pizza program for ordering a pizza and I have removed all the errors except for two. I have tried everything I can think of to fix this problem so it will compile, but to no avail. The only errors left are:
1>------ Rebuild All started: Project: Pizza Order App Midterm, Configuration: Debug Win32 ------ 1> stdafx.cpp 1> Pizza Order Midterm.cpp 1> Pizza Order App Midterm.cpp 1>c:usersindia-n-jerrydocumentsvisual studio 2010projectspizza order app midtermpizza order app midtermpizza order app midterm.cpp(57): warning C4390: ';' : empty controlled statement found; is this the intent?
[Code] ....
The entire code is listed below seperated into 1 header and 2 cpp files.
// OrderPizzaApp.cpp : Defines the entry point for the console application.//
I have an if statement that should either match a text variable that the user has entered and a another text variable that has been got from an array but they won't match even if they are the same,Im at a lost with it.
Ok, so this assignment is to create a structure that allows input for up to 6 employees that then makes a 6 structure array showing Employee ID, Employee Last Name, Employee Pay Rate, Employee Hours Worked, Employee Pay, and Total Gross Pay for All Employees.
I don't have a printf yet for total gross, but right now I am just trying to tackle the input. Obviously I am not doing it right because although gcc complier is not giving errors the program is not ending when I type 'q' (sentinel issue) or when I reach 6 employees. It just continues input forever. Here is my code so far:
Code: //Cameron Taylor #include <stdio.h> #define MAXARRAY 6 struct Record{ int idnum; char lname[20]; double pay_rate;
Okay, I'm not entirely certain where my code is messed up, but when I run the console it asks if I want to add Employee information and then it just skips through everything when I say yes.
I am having some trouble with my class assignment. We need to write a C program that will calculate the employee salary. There are 5 employees that will need to be calculated. We are required to use a loop also.
So far this is what I have but I am receiving errors when running the program.
#include <stdio.h> int main() { int clock_num; /* employee clock number */ float gross; /* gross pay for week (wage * hours) */ float hours; /* number of hours worked per week */ float wage; /* hourly wage */ /* Prompt for input values from the screen */ printf ("This is a program to calculate gross pay.
This refers to an ATL COM DLL project. I can successfully create a class hierarchy of objects, ie. say, one class is the TEAM, which then holds other objects, say, a leader and a secretary, both of which are Employee Classes . Here goes my question:
a) In the Team.h header file I declare m_pLeader as a CComPtr<IEmployee>
Code: classATL_NO_VTABLE CTeam : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CTeam, &CLSID_Team>, public IDispatchImpl<ITeam, &IID_ITeam, &LIBID_BUOBJ05Lib, /*wMajor =*/ 1, /*wMinor =*/ 0> { private: CComPtr<IEmployee> m_pLeader; CComPtr<IEmployee> m_pSecretary;
b) The Employee Class is defined within this ATL COM project. c) In the Team.cpp file, I create an instance in the FinalConstruct code, the focus is on the CEmployee
Code: HRESULT CTeam::FinalConstruct(){ CComObject<CEmployee>* pLeader; HRESULT hr=CComObject<CEmployee>::CreateInstance(&pLeader); if (FAILED(hr)) return hr; m_pLeader=pLeader; // ..same for secretary... return S_OK }
d) Here comes my QUESTION: How must I proceed if the Employee object was part of another ATL COM DLL, that is it would be described in another DLL that I would now like to reuse? I guess I need to
1. Have the other DLL's idl-, tlb, and h file in my project folder. Let me name it "other.h, other.idl, other.tlb"
2. Both h- and cpp-file must have an #include "other.h" statement -- please correct if I am wrong..
3. ...but how must in the Team's h- and cpp-files the statements be (assuming the class in the "other" Dll is Member (instead of Employee? I know the following code will NOT work, so I am asking how it should be correctly?
The program that I have written below is working. It calculates a number of payroll type variables and most recently the net pay average (All this is working 100%).
My problem is that I need to add first and last employee names to the program but every time I do this I end up ruining the working program. I've successfully added first and last names to similar programs in the past(ones that make use of an array and while loop) but never to a program that uses functions (I always have problems doing this).
My question is what codes do I use to add a first and last name variable and where do I put those codes within my program so it runs/displays correctly.
I think the coding must be similar to what I've used in the past charr and of course firstname[i] and lastname[i] lines.
Current Input File: 16454025.00 89324020.00 71044012.50 28164026.00 53874021.00 67804013.50 56414011.25
90006025.00 90015020.00 90025523.00
Ideal input file (would include names) Example. 1645 Bob Smith 40 25.00