请帮助解决System.Data.SqlClient.SqlException [英] Please help resolving System.Data.SqlClient.SqlException
本文介绍了请帮助解决System.Data.SqlClient.SqlException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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;
}
}
推荐答案
您没有给出文档表的别名。
通过这种方式修改查询
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
您在加入时错过了表别名'a'。
试试这个 -
You have missed the table alias 'a' in the joining.
Try this-
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 :)
你忘了定义a
更改
You forgot to definea
Change
"Select documentid,title from document inner join Company b on a.companyid = b.companyid where b.ParentCompanyId = 428 "
要
To
"Select documentid,title from document a inner join Company b on a.companyid = b.companyid where b.ParentCompanyId = 428 "
这篇关于请帮助解决System.Data.SqlClient.SqlException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文