if else condition between table ,how it will use
i have item master table in which column are (itemcode,itemname,weight) and second one table is customer item table(citemcode,citemname,customerid,itemcode),

third table is customer (customerid,customername)

fourth table is produce item (prodno,itemcode,itemname,weight,orderno).

fifth table sales…
like this?

select a.itemcode

,isnull(c.citemname,b.itemname)

from produceitem as a

left outer join mastertable as b

on b.itemcode=a.itemcode

left outer join customeritemtable as c

on c.itemcode=a.itemcode

;
Your test is redundant, since you are already querying only for matching records. In this case, you will get no rows if there is no match, therefore you will never hit the else clause in the loop.  

  

Instead, it is enough to check if there are any matching records at all. The example below shows how (note that you can put a condition straight into Any() instead of specifying Where()).  

  

C#Copy Code

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace CustomerMaster
{
    public partial class CustomerMaster : System.Web.UI.Page
    {
 
        private void AddData()
        {
            
            OperationsDataContext AddDb = new OperationsDataContext();
            CustomerMast cm = new CustomerMast();
            
                        
            cm.CustomerCode = txtCustCde.Text;
            cm.CustomerName = txtCustName.Text;
            cm.CustomerAddress = txtCustAdd.Text;
            cm.BrkrCode = txtBrkCode.Text;
            cm.BrokerName = txtBrkName.Text.
            cm.CrrCode = txtCrrCode.CarrierCode;
            cm.CarrierName =  txtCrrName.Text;
            cm.StnCode=sm.StationCode;
            cm.StationName = txtStnName.Text;
            cm.VatNo=txtVatNo.Text;
            cm.TinNo=txtTinNo.Text;
            cm.TMCO=txtTMCONo.Text;
            cm.PanNo = txtPAN.Text;
			
	    if(AddDb.CustomerMasts.Any(c=>c.CustomerCode == txtCustCde.Text))
            {
	        Response.Write("Error! CustomerCode Exits");
	    }
	    else
	    {
                AddDb.BrokerMasts.InsertOnSubmit(bm);
                AddDb.CarrierMasts.InsertOnSubmit(crm);
                AddDb.StationMasts.InsertOnSubmit(sm);
                AddDb.CustomerMasts.InsertOnSubmit(cm);

	        AddDb.SubmitChanges();
            }         
        }
 
        protected void btnAdd\_Click(object sender, EventArgs e)
        {
            AddData();
        }
    }
}
``` you might be able to use synchronize. if you have more than 2 tables, you will need to use it multiple times. hi,

lots of great explanations below, but i fear they might be difficult to truly conceptualize. 

let's start with a pie!

if there's a pie in front of us, that is the market. we'll call it 100 units of pie

we cut the pie in half - one piece (50 pie units) for you, and one piece (50 pie units) for me

scenario 1: we do nothing, we both have 50% market share.

scenario 2: i eat half my pie. my pie slice is now 25 units, yours is still 50 units. as a result, you have 67% of the market share and i have 33%. my "revenues" have fallen and my market share has fallen. your revenues haven't changed but you've gained market share

scenario 3: not only do i eat half my pie, but you also eat 20% of yours. still, i ate more, so even though your "revenues" are down, you've still gained market share.

scenario 4: we both get given more pie (yay). but, i get a whole other 50 units, and you only get 5 more. your "revenues" are up, but you've still lost market share!

i've created the below image for you to visualize this better (click on it to blow it up)...hope this helps! hi paul,

i believe the financial reporting covers in quite a lot of detail exactly what you are looking for.

from what i can tell you aren’t using templates in your tables…

[[image]](https://forum.enterprisedna.co/uploads/db7134/original/2x/5/559a333f85c159c8d9bec9235ca5c45997d08858.png "image")

if you want to get a certain order and custom table then you really need to use the template approach covered in t… hi [@jitse\_b](/u/jitse_b)

welcome to the community !

yes you can, there are various ways to do so.

the simplest:

you may want to create a table with 3 columns,

key\_column, type text, value “k000” (or whatever you want, it doesn’t matter if you stick to only one comparison)

“material1”, type ref, source tabl… hi stuti, 
index can be used with lists, not tables. 
if a variable is used as an index, it is put in the square brackets without the dollar sign and curly brackets, i.e. ${data\_list[item\_index]}. 
you can read more about using indexes with lists in the knowledge base: [https://kb.workfusion.com/disp…](https://kb.workfusion.com/display/rpae/recorder+variables#recordervariables-usingindexeswithlists) unfortunately that's not how it works. it's db mapping, and we're talking about joined-tables hierarchy. so the "other side" of the association must be in the referenced table (the detail one, not custom detail). Thanks for your reply, I feared it would not be trivail, as I coudnt find any scripts. Idealy the text from the databse is place in a table witht the last column beeing the barcodes path, the images are to replace the text path and be place inside the cell, fitting within the cells width and/or height. use sections. the first page should be section 1. you can assign the master page elements to that section only. then all other pages will be in section 2, with a different master page with different elements. each section can pick up page numbering from the last or start at a new number. Lets say you want to send a table with a single column of GUIDs.


First we need to create a structure using [SqlMetaData](https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.server.sqlmetadata(v=vs.110).aspx) which represents the schema of the table (columns).



```
var tableSchema = new List<SqlMetaData>(1)
{
  new SqlMetaData("Id", SqlDbType.UniqueIdentifier)
}.ToArray();

```

Next you create a list of records that match the schema using [SqlDataRecord](https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.server.sqldatarecord(v=vs.110).aspx).



```
var tableRow = new SqlDataRecord(tableSchema);
tableRow.SetGuid(0, Guid.NewGuid());
var table = new List<SqlDataRecord>(1)
{
  tableRow
};

```

Then create the [SqlParameter](https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter(v=vs.110).aspx):



```
var parameter = new SqlParameter();
parameter.SqlDbType = SqlDbType.Structured;
parameter.ParameterName = "@UserIds";
parameter.Value = table;

var parameters = new SqlParameter[1]
{
  parameter
};

```

Then simply call the stored procedure by using the [Database.SqlQuery](https://msdn.microsoft.com/en-us/library/gg696545(v=vs.113).aspx).



```
IEnumerable<ReturnType> result;
using (var myContext = new DbContext())
{
  result = myContext.Database.SqlQuery<User>("GetUsers", parameters)
    .ToList();         // calls the stored procedure
    // ToListAsync();  // Async
{

```

In SQL Server, create your User-Defined Table Type (I suffix them with TTV, Table Typed Value):



```
CREATE TYPE [dbo].[UniqueidentifiersTTV] AS TABLE(
  [Id] [uniqueidentifier] NOT NULL
)
GO

```

Then specify the type as a parameter (don't forget, Table Type Values have to be readonly!):



```
CREATE PROCEDURE [dbo].[GetUsers] (
  @UserIds [UniqueidentifiersTTV] READONLY
) AS
BEGIN
  SET NOCOUNT ON

  SELECT u.* -- Just an example :P
  FROM [dbo].[Users] u
  INNER JOIN @UserIds ids On u.Id = ids.Id
END

```