用数据适配器查询结果填充数据集C#Asp.Net

用数据适配器查询结果填充数据集C#Asp.Net,c#,asp.net,sql-server-2008,tsql,C#,Asp.net,Sql Server 2008,Tsql,我正在使用C#和Asp.Net。我有以下数据适配器和数据集: SqlDataAdapter da_Select_Matching_Records; DataSet ds_for_showing_X_Rows_Cols = new DataSet(); 我想填写数据集ds\u,以便用查询结果显示\ux\urows\ucols。这是我的密码: con = new SqlConnection("Data Source=local;Initial Catalog=Test;Integrated

我正在使用C#和Asp.Net。我有以下数据适配器和数据集:

SqlDataAdapter da_Select_Matching_Records;
DataSet ds_for_showing_X_Rows_Cols = new DataSet();
我想填写数据集
ds\u,以便用查询结果显示\ux\urows\ucols
。这是我的密码:

    con = new SqlConnection("Data Source=local;Initial Catalog=Test;Integrated Security=True");

da_Select_Matching_Records = new SqlDataAdapter("Select BusinessSector5.Description_DE, SubCategory.Kategorie "+
"FROM   Match_Subcategory_BusinessSector5 INNER JOIN "+
" SubCategory ON Match_Subcategory_BusinessSector5.SubCategoryID = SubCategory.ID INNER JOIN "+
" BusinessSector5 ON Match_Subcategory_BusinessSector5.BusinessSector5ID = BusinessSector5.ID", con);

//Filling of Data Set
da_Select_Matching_Records.Fill(ds_for_showing_X_Rows_Cols, "Description_DE, Kategorie");
我在填充数据集的线路上遇到了这个错误。我在SQLServerManagementStudio中使用了该查询,它运行正常

Incorrect syntax near the keyword INNER.

您需要在此行末尾添加一个空格:

"FROM   Match_Subcategory_BusinessSector5 INNER JOIN"+
i、 e

这一行也一样:

"SubCategory ON Match_Subcategory_BusinessSector5.SubCategoryID = SubCategory.ID  INNERJOIN"+
internal
JOIN
之间也没有空格


因此,为了确认,请在所有行中添加一个尾随空格,并在inner和join之间添加一个空格

您也应该对查询进行参数化,以避免sql注入:在每行中添加一个空格是的,我添加了空格,但仍然得到相同的错误。然后,我还在其他行上添加了空格,但仍然得到了相同的错误。此行末尾也有一个空格:Select BusinessSector5.Description\u DE,SubCategory.Kategorie“+内部连接之间的空格,即内部连接请将更新的代码添加到问题中?我现在拿到了。这一行的末尾缺少一个空格。“选择BusinessSector 5.Description\u DE,SubCategory.Kategorie”。我现在添加了空间和它的工作。谢谢
"SubCategory ON Match_Subcategory_BusinessSector5.SubCategoryID = SubCategory.ID  INNERJOIN"+