|
 |
|
SelectCommand ของ SqlDataSource เซ็ตได้ไหม (SELECT * FROM [cart] WHERE [Username] = Session['strUsername']) |
|
 |
|
|
 |
 |
|
ต้องการใช้ Session['strUsername'] เป็นตัวคนหาตาราง
Code (C#)
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [cart] WHERE [CartId] = @CartId"
InsertCommand="INSERT INTO [cart] ([Username], [ProductId], [ProductName], [OrderDate], [Qty], [TotalPrice]) VALUES (@Username, @ProductId, @ProductName, @OrderDate, @Qty, @TotalPrice)"
SelectCommand="SELECT * FROM [cart] WHERE [Username] = Session['strUsername'] "
Tag : ASP

|
|
 |
 |
 |
 |
Date :
2012-09-03 13:43:32 |
By :
thewinner55 |
View :
1111 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ผ่านพวก Parameter ครับ ตัวอย่าง
Code (VB.NET)
<asp:sqlDataSource ID="EmployeeDetailsSqlDataSource"
SelectCommand="SELECT EmployeeID, LastName, FirstName FROM Employees WHERE EmployeeID = @EmpID"
InsertCommand="INSERT INTO Employees(LastName, FirstName) VALUES (@LastName, @FirstName);
SELECT @EmpID = SCOPE_IDENTITY()"
UpdateCommand="UPDATE Employees SET LastName=@LastName, FirstName=@FirstName
WHERE EmployeeID=@EmployeeID"
DeleteCommand="DELETE Employees WHERE EmployeeID=@EmployeeID"
ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>"
OnInserted="EmployeeDetailsSqlDataSource_OnInserted"
RunAt="server">
<SelectParameters>
<asp:Parameter Name="EmpID" Type="Int32" DefaultValue="0" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="EmpID" Direction="Output" Type="Int32" DefaultValue="0" />
</InsertParameters>
</asp:sqlDataSource>
|
 |
 |
 |
 |
Date :
2012-09-03 21:42:12 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|