Reputation: 1425
I tried but it gives this error
Must declare the scalar variable "@imageid"
controller.cs
[HttpGet]
[Route("download/{id:int}")]
public String Getfiles(int imageid)
{
return _ShopDataProvider.DownloadImage(imageid);
}
class.cs
public String DownloadImage(int imageid)
{
using(IDbConnection dbConnection = Connection)
{
string sQuery0 = "SELECT path FROM Shop WHERE ShopId = @imageid";
dbConnection.Open();
String Path = dbConnection.QueryFirstOrDefault<String>(sQuery0, new { ShopId = imageid });
return Path;
}
}
Upvotes: 0
Views: 1331
Reputation: 59016
You're declaring a parameter in your SQL query named @imageid
but not providing a value for it. You're providing a value for the parameter @ShopID
(new { ShopId = imageid }
), which your SQL query doesn't use.
Change new { ShopId = imageid }
to new { imageid = imageid }
Please refer to the documentation.
Upvotes: 2