Monday, March 26, 2012

it will not show the data from the DB

is have this code, and i know that i have a record with the ID=1 but it will not show the data from the record..

<asp:Content ID="Main" ContentPlaceHolderID="ContentPlaceHolderMain" Runat="Server"><asp:FormView ID="form1" runat="server" DataSourceID="SqlDataSource1"></asp:FormView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnStrAccess%>" SelectCommand="SELECT [MainID], [MainText] FROM [SiteText] WHERE ([MainID] = ?)" ProviderName="<%$ ConnectionStrings:ConnStrAccess.ProviderName%>"> <SelectParameters> <asp:SessionParameter DefaultValue="1" Name="SiteMainID" Type="Int32" /> </SelectParameters></asp:SqlDataSource></asp:Content>
Why can't it show the record !??

Hello:

A few things are not right here:

1. YourSelectCommand should be:SelectCommand="SELECT [MainID], [MainText] FROM [SiteText] WHERE ([MainID] = @.MainID)" Yours (the ? is not forSqlDataSource);

2. The SessionParameter should look like:

<asp:SessionParameter DefaultValue="1" Name="MainID" SessionField="yourSessionMainIDValue" Type="Int32" />;
3.Your FormView should include at lease the <ItemTemplate> section to show your data.

Hope you can get your Access table work here.

|||Thx now it's worksYes

No comments:

Post a Comment