It seems that I am an idiot, trying to perform a simple query to a SQL database in C#.
This is the query, I am trying to execute:
_query = "SELECT PC.SN, User.Name + ' ' + User.Family as AssignedTo " +
"FROM PC LEFT JOIN Users ON PC.USERID = Users.ID " +
"WHERE PC.Type = '" + AssetTypeCB.SelectedItem.ToString() + "'";
The problem is that I am getting a “cannot call methods on nvarchar” error message.
Do you have any idea what might be the issue?
Your query seems wrong. You need to change
User.NametoUsers.Name, et al. The correct query would be:Also, allow me to suggest using parameterized queries for your code. This can tell you why you should.