Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public DataSet GetDocumentForBPRA(int CompanyId)
        {
            try
            {
                SqlConnection conn = new SqlConnection(objConnection.GetConnection());
                DataSet DsLoginData = new DataSet();

                DsLoginData = SqlHelper.SqlHelper.ExecuteDataset(conn, CommandType.Text, "Select documentid,title from document inner join Company b on a.companyid = b.companyid where b.ParentCompanyId = 428  ");
                DsLoginData.Tables[0].TableName = "Document";
                // DsLoginData.Tables[1].TableName = "Contacts";
                return DsLoginData;

            }
            catch (Exception)
            {

                throw;
            }
        }
Posted
Updated 29-Jun-15 0:29am
v2

You have not given the alias name of "document" Table .
Modify the query by this way
Select documentid,title from document a inner join Company b on a.companyid = b.companyid where b.ParentCompanyId = 428

Thanks
 
Share this answer
 
v2
You have missed the table alias 'a' in the joining.
Try this-

C#
DsLoginData = SqlHelper.SqlHelper.ExecuteDataset(conn, CommandType.Text, "Select documentid,title from document a inner join Company b on a.companyid = b.companyid where b.ParentCompanyId = 428  ");


Hope, it helps :)
 
Share this answer
 
You forgot to define a
Change
SQL
"Select documentid,title from document inner join Company b on a.companyid = b.companyid where b.ParentCompanyId = 428 "
To
SQL
"Select documentid,title from document a inner join Company b on a.companyid = b.companyid where b.ParentCompanyId = 428 "
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900