BlackOps
November 18th, 2007, 11:02 AM
Hello guys,
i am implementing database of the Employees and their PassCards.
i am writing a code using C# from scratch (dont use AddDatabase file wizards..etc.) dont know is it nice idea or no? i am doing it because i wanted to also to understand how it works...
ok, now a problem is, i have placed some text boxes on the form, some buttons (next,previous,last...etc)
my database file has 7 tables. i use SQL statement to select from tables:
String sql2 = "SELECT e_employees.FirstName, e_employees.LastName, d_divisions.DivisionName, d_departments.DepName, t_titles.TitleName" +
" FROM t_titles INNER JOIN ((d_divisions INNER JOIN d_departments ON d_divisions.DivisionID = d_departments.DivisionID) INNER JOIN e_employees ON " +
"d_departments.DepartmentID = e_employees.DepartmentID) ON t_titles.TitleID = e_employees.TitleID;";
This gives me FirstName,Last name from e_employees table. DepName from d_departments table. DivisionName from d_divisions table. and Titlename from t_titles table.
problem is, i cannot SAVE data to multiple tables...
here is my Save Button Code:
//============SAVING DATA======================================
private void btnSave_Click(object sender, EventArgs e)
{
// If there is existing data, update it.
if (mEmployees.Rows.Count != 0)
{
mEmployees.Rows[m_rowPosition]["FirstName"] = txtFirstName.Text;
mEmployees.Rows[m_rowPosition]["LastName"] = txtLastName.Text;
//mEmployees.Rows[m_rowPosition]["DivisionName"] = txtLastName.Text;
mDataAdapter.Update(mEmployees);
}
}
i have uncommented line of code saving to DivisionName, because when it is on, code compiles successfully, but it gives SQL error(Dynamic SQL generation is not supported against multiple base tables.), that one cannot update multiple table.
could u say me another method of updating multiple tables?
thanks
ps.i have looked at many codes, but didnt find any nice sample code with such issue
attached file is architecture of my database
i am implementing database of the Employees and their PassCards.
i am writing a code using C# from scratch (dont use AddDatabase file wizards..etc.) dont know is it nice idea or no? i am doing it because i wanted to also to understand how it works...
ok, now a problem is, i have placed some text boxes on the form, some buttons (next,previous,last...etc)
my database file has 7 tables. i use SQL statement to select from tables:
String sql2 = "SELECT e_employees.FirstName, e_employees.LastName, d_divisions.DivisionName, d_departments.DepName, t_titles.TitleName" +
" FROM t_titles INNER JOIN ((d_divisions INNER JOIN d_departments ON d_divisions.DivisionID = d_departments.DivisionID) INNER JOIN e_employees ON " +
"d_departments.DepartmentID = e_employees.DepartmentID) ON t_titles.TitleID = e_employees.TitleID;";
This gives me FirstName,Last name from e_employees table. DepName from d_departments table. DivisionName from d_divisions table. and Titlename from t_titles table.
problem is, i cannot SAVE data to multiple tables...
here is my Save Button Code:
//============SAVING DATA======================================
private void btnSave_Click(object sender, EventArgs e)
{
// If there is existing data, update it.
if (mEmployees.Rows.Count != 0)
{
mEmployees.Rows[m_rowPosition]["FirstName"] = txtFirstName.Text;
mEmployees.Rows[m_rowPosition]["LastName"] = txtLastName.Text;
//mEmployees.Rows[m_rowPosition]["DivisionName"] = txtLastName.Text;
mDataAdapter.Update(mEmployees);
}
}
i have uncommented line of code saving to DivisionName, because when it is on, code compiles successfully, but it gives SQL error(Dynamic SQL generation is not supported against multiple base tables.), that one cannot update multiple table.
could u say me another method of updating multiple tables?
thanks
ps.i have looked at many codes, but didnt find any nice sample code with such issue
attached file is architecture of my database