Parameter fra URL skal ind i SQL kald til AccessDB
Som ny .NET bruger synes jeg godt nok alting er meget anderledes end gode gamle ASP3.0, men hva...Er der en der vil være så flink at skrive ind i medsendte kode, det nødvendige for at SQL kaldet i Where delen ikke blot kalder Main.ID = 3 men Main.ID = request.querystring("ID").
Man må gerne gemme request.querystring("ID") i en variabel først (ex. xvar eller lignende)
jeg synes jeg har prøvet al verdens ting, ergo må jeg være dum!
koden:
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub DetailsView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewPageEventArgs)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Product Database</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
CellPadding="4" DataSourceID="details" ForeColor="#333333" GridLines="None" Height="1px"
OnPageIndexChanging="DetailsView1_PageIndexChanging" Style="z-index: 100; left: 0px;
position: absolute; top: 0px" Width="349px">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<EditRowStyle BackColor="#999999" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<Fields>
<asp:BoundField DataField="t_dsca" HeaderText="Product Group" SortExpression="t_dsca" />
<asp:BoundField DataField="ProductType" HeaderText="Product Type" SortExpression="ProductType" />
<asp:BoundField DataField="ProductDescription" HeaderText="Product Description" SortExpression="ProductDescription" />
<asp:BoundField DataField="Version" HeaderText="Version" SortExpression="Version" />
<asp:BoundField DataField="Responsable" HeaderText="In Charge" SortExpression="Responsable" />
<asp:BoundField DataField="LifeTimeStatus" HeaderText="Life Time Status" SortExpression="LifeTimeStatus" />
<asp:BoundField DataField="Signal" HeaderText="Signal" SortExpression="Signal" />
<asp:BoundField DataField="CaseIPU" HeaderText="Case IPU" SortExpression="CaseIPU" />
<asp:CheckBoxField DataField="PriceList" HeaderText="Price List" SortExpression="PriceList" />
<asp:BoundField DataField="LastEdit" HeaderText="Last Edited" SortExpression="LastEdit" />
</Fields>
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:DetailsView>
<asp:AccessDataSource ID="details" runat="server" DataFile="\\neptun\dbroot\ProductDB\ProductDB.mdb"
SelectCommand="SELECT dbo_ttcmcs0442001.t_dsca, Main.ProductType, Main.ProductDescription, Main.Version, Main.Responsable, Main.LifeTimeStatus, Main.Signal, Main.CaseIPU, Main.PriceList, Main.LastEdit FROM ((Main INNER JOIN dbo_ttcmcs0442001 ON Main.ProductGroup = dbo_ttcmcs0442001.t_csgp) LEFT OUTER JOIN SignalList ON Main.Signal = SignalList.Signal) Where Main.ID = 2" >
</asp:AccessDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CaptionAlign="Left"
DataSourceID="Productdata" Style="z-index: 102; left: 83px; position: absolute;
top: 325px" Width="190px">
<Columns>
<asp:BoundField DataField="Data" HeaderText="Data" SortExpression="Data" />
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="Productdata" runat="server" DataFile="\\neptun\dbroot\productdb\productdb.mdb"
SelectCommand="SELECT Data FROM ProductData WHERE (ID = 3)"></asp:AccessDataSource>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"></asp:AccessDataSource>
</div>
</form>
</body>
</html>
