1

I am working with C# and Asp.Net. I have following data adapter and Data set:

SqlDataAdapter da_Select_Matching_Records;
DataSet ds_for_showing_X_Rows_Cols = new DataSet();

I want to fill in the Data Set ds_for_showing_X_Rows_Cols with the query results. Here is my Code:

    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");

I am getting this error, on the line where I am filling the data set. I used the query in Sql Server management studio and its running OK.

Incorrect syntax near the keyword INNER.
2

1 Answer 1

3

You need to add a space at the end of this line:

"FROM   Match_Subcategory_BusinessSector5 INNER JOIN"+

i.e.

"FROM   Match_Subcategory_BusinessSector5 INNER JOIN "+

the same with this line too:

"SubCategory ON Match_Subcategory_BusinessSector5.SubCategoryID = SubCategory.ID  INNERJOIN"+

You've also got no space between INNER and JOIN.

So to confirm, add a trailing space to all lines and a space between inner and join

Sign up to request clarification or add additional context in comments.

6 Comments

Yes I added the space but still I am getting the same error. Then I also added space on other lines but still getting the same error.
A space on the end of this line too: Select BusinessSector5.Description_DE, SubCategory.Kategorie"+
A space between INNERJOIN i.e. INNER JOIN
Please can you add your updated code to the question? Just so I can re-check it.:)
I got it now. There was a space missing the end of this line. "Select BusinessSector5.Description_DE, SubCategory.Kategorie". I added the space and its working now. Thanks
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.