I want to execute this query after Checking Databse is Empty or not.
if Database is Empty Then it executes Otherwise Warning Message appears.
Or there is another way to write this SQL query ??
public void InsertIntoNew()
{
con = new SqlConnection("Data Source=Shubham-PC;Initial Catalog=SABillPay;Integrated Security=True");
str1 = "Insert Into SumBill(Code,Customer,NetBill) Select code,customer,sum(amount) from Bills Group By Code,Customer order by code";
str2 = "Insert Into SumPay(Code,Customer,NetPay) Select code,customer,sum(amount) From Payments Group By Code,Customer Order By Code";
cmd = new SqlCommand(str1, con);
cmd1 = new SqlCommand(str2, con);
//cmd.ExecuteNonQuery();
//cmd1.ExecuteNonQuery();
I am having two table Bills And Payments..
There are three columns in both the table- ID,Name,Amonut.
There is no column having Primary Key Because they have same values in more than one row.
so how to sum the amount of same ID..
Example--
ID Name Amount
1 as 5
1 as 10
1 a 4
2 a 5
2 a 5
because there is no primary key so on any button event data is replicated. i want to insert it only for once and next time it check that it has not the same value i table..
ID Name Amount
1 as 15
1 a 4
2 a 10