Last post Jun 12, 2017 09:24 PM by jackh123
Jun 12, 2017 07:30 PM|jackh123|LINK
I have a grid view that I want to use 2 tables: Table 1 contains user's username and a vehicle ID, the other table contains all details of the vehicle (inc. ID).
Here's the query I have now:
"SELECT userStock.username, stock.vehID, stock.make, stock.model, stock.price, stock.regDate, stock.milage, stock.fuelType, stock.engineSize, stock.gearbox, stock.doors, stock.seats, stock.colour
FROM stock INNER JOIN userStock ON stock.vehID = custstock.vehID
WHERE ([username] = Session["username"])
ORDER BY make, model ASC"
This is currently in the HTML and so doesn't work because I need the session variable.
Where in the C# do I put this code?
Jun 12, 2017 07:35 PM|oned_gk|LINK
Usualy you can use parameterize query like this
WHERE ([username] = @username)
Then pass @username value from the session, if you use sqldatasource, add sessionparameter in selectparameters
Jun 12, 2017 09:24 PM|jackh123|LINK
Thanks! I configured the Data Source and put @username and then asked me which parameter I wanted to use. I didn't realise it did that!