Hi together
I developed a litte programm which does following:
It subctrats the open bills from the salary and calculate a daily limit
Now i do a Subselect (see code snippet below) to get 2 Values from 2 Tables in SQL Database
(dbo.Limiten and dbo.Ausgaben)
How can i do a compare, so if the total of all "Ausgaben" is higher than the daily limit
for example if the limit exeeced the total
Hope i have explained good cause my english is not so good..
I developed a litte programm which does following:
It subctrats the open bills from the salary and calculate a daily limit
Now i do a Subselect (see code snippet below) to get 2 Values from 2 Tables in SQL Database
(dbo.Limiten and dbo.Ausgaben)
C#:
private void Alarm_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
OleDbDataReader reader;
con.ConnectionString = "Provider=SQLNCLI11.1;" + "Data Source=CRONOS-WI764BIT;Initial Catalog=Tageslimit;Persist Security Info=True;User ID=sa;Password=satest$";
cmd.Connection = con;
// Limite abzüglich Summe der Ausgaben ergibt Differenz die bei Ueberschreitung rotes Label anzeigt
cmd.CommandText = "Select (Select (Nettolohn - Zahlungen) / 30 As Resultat from Limiten) - (Select SUM(Preis) AS Summe from Ausgaben) AS Differenz from Ausgaben";
try
{
con.Open();
reader = cmd.ExecuteReader();
LstAnzeige3.Items.Clear(); // Liste leeren
while (reader.Read()) // Der Zugriff auf die DB geht solange bis der letzte Datensatz erreicht wurde
{
LstAnzeige3.Items.Add("Tageslimite abzüglich Summe der Ausgabe pro Tag " + reader["Differenz"]);
}
reader.Close(); // "Reader" schliessen
con.Close(); // dasselbe mit der Verbindung zur DB
}
catch (Exception ex) // gibts ein Problem?
{
MessageBox.Show(ex.Message); // dann Fehlermeldung ausgeben
}
How can i do a compare, so if the total of all "Ausgaben" is higher than the daily limit
for example if the limit exeeced the total
Hope i have explained good cause my english is not so good..