I’m trying to build a SharePoint web part in c# that will pull SQL data into a drop down list and filter the results based on the current user.
So far I’ve managed to pull the data from SQL but when I’ve tried to filter it I get the error message
“Incorrect syntax near ‘Account’”
The code I’ve used to get the SP user is
SPUser currentUser = SPContext.Current.Web.CurrentUser; String userName = currentUser.Name;
And the Where clause is
”…where useritem.name =”+ currentUser.Name, MySQLconnection);
I’m a complete c# newbie so I’ve had to guess this from other bits of code I’ve seen.
If someone could point me in the right direction that would be great!