selectcommand table variable

Anthony Cardullo
Anthony Cardullo used Ask the Experts™
on
I have users open a url link that passes var to a webpage which in turn runs a select statement against my sql server.  working great. See code.

The url is http://Mywebsite.com/Pagename.aspx?Leasenum=03011870?TableName=TableVariable

i want the From Tablename substituted with the tablename  variable  in the url.

THank you
<asp:SqlDataSource ID="Boutlist" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Connstring %>"             
        
        
        SelectCommand="SELECT [Status],[Lease], [End Date] AS End_Date, [Customer Name] AS Customer_Name
        , [Trade Up] AS Trade_Up, [Past Due Invoices] AS Past_Due_Invoices
        , [FF Start] AS FF_Start, [FF End] AS FF_End, [Fast Forward Past Due] AS Fast_Forward_Past_Due
         FROM [Tablename] WHERE ([Lease] = @Lease)">
            <SelectParameters>
                <asp:QueryStringParameter Name="Lease" QueryStringField="Leasenum" 
                    Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I would think the easiest way would be to move your SelectCommand to your code file:

Boutlist.SelectCommand = "SELECT [Status],[Lease], [End Date] AS End_Date, [Customer Name] AS Customer_Name
        , [Trade Up] AS Trade_Up, [Past Due Invoices] AS Past_Due_Invoices
        , [FF Start] AS FF_Start, [FF End] AS FF_End, [Fast Forward Past Due] AS Fast_Forward_Past_Due
         FROM " + Request.QueryString["TableName"] + " WHERE ([Lease] = @Lease)"
Anthony CardulloSystem Administrator

Author

Commented:
easy if you know how to do that. i ' don's so walk me thorugh it.  what do i remove from the main page and hopw and what do i put in the code page?
Anthony CardulloSystem Administrator

Author

Commented:
This is my code page

and below is my aspx page

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="NewEngland.aspx.vb" Inherits="BuyoutPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style2
        {
            height: 551px;
        }
        .style3
        {
            height: 25px;
            width: 76px;
        }
    </style>
   
</head>
<body>


    <form id="form1" runat="server" class="style2">
    <div>
   
        &nbsp;<br />
         
        <br />
       
   
        <asp:DataList ID="DataList1" runat="server" DataSourceID="Boutlist"
            Height="228px" RepeatDirection="Horizontal" style="margin-top: 50px"
            Width="520px">
            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
                VerticalAlign="Top" />
            <ItemTemplate>
                Status:
                <asp:Label ID="StatusLabel" runat="server" Text='<%# Eval("Status") %>' />
                <br />
                Lease:
                <asp:Label ID="LeaseLabel" runat="server" Text='<%# Eval("Lease") %>' />
                <br />
                End_Date:
                <asp:Label ID="End_DateLabel" runat="server"
                    Text='<%# Eval("End_Date") %>' />
                <br />
                Customer_Name:
                <asp:Label ID="Customer_NameLabel" runat="server"
                    Text='<%# Eval("Customer_Name") %>' />
                <br />
                Trade_Up:
                <asp:Label ID="Trade_UpLabel" runat="server"
                    Text='<%# Eval("Trade_Up") %>' />
                <br />
                Past_Due_Invoices:
                <asp:Label ID="Past_Due_InvoicesLabel" runat="server"
                    Text='<%# Eval("Past_Due_Invoices") %>' />
                <br />
                FF_Start:
                <asp:Label ID="FF_StartLabel" runat="server" Text='<%# Eval("FF_Start") %>' />
                <br />
                FF_End:
                <asp:Label ID="FF_EndLabel" runat="server"
                    Text='<%# Eval("FF_End") %>' />
                <br />
                Fast_Forward_Past_Due:
                <asp:Label ID="Fast_Forward_Past_DueLabel" runat="server"
                    Text='<%# Eval("Fast_Forward_Past_Due") %>' />
                <br />
                <br />
            </ItemTemplate>
        </asp:DataList>
        <br />
        <asp:TextBox ID="TextBox1" runat="server" Font-Size="Small"
            Height="33px" Width="534px" BorderStyle="None" Font-Bold="True">All past due amounts need to be added to the Trade up Amount!</asp:TextBox>
   
        <br />
        <asp:TextBox ID="TextBox2" runat="server" Font-Size="Small" Width="914px"
            BorderStyle="None" Font-Bold="True">These figures are estimates and any written order will need to be accompanied by an official trade up quote from MailFinance.</asp:TextBox>
   
        <br />
        <br />
   
        <br />
   
    </div>
       
        <asp:SqlDataSource ID="Boutlist" runat="server"
            ConnectionString="<%$ ConnectionStrings:NewEnglandBO %>"
           
                 
       
        SelectCommand="SELECT [Status],[Lease], [End Date] AS End_Date, [Customer Name] AS Customer_Name
        , [Trade Up] AS Trade_Up, [Past Due Invoices] AS Past_Due_Invoices
        , [FF Start] AS FF_Start, [FF End] AS FF_End, [Fast Forward Past Due] AS Fast_Forward_Past_Due
         FROM [tbl_NewEnglandBO] WHERE ([Lease] = @Lease)">
            <SelectParameters>
                <asp:QueryStringParameter Name="Lease" QueryStringField="Leasenum"
                    Type="String" />
                    <asp:QueryStringParameter Name="table" QueryStringField="Tablename"
                    Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
    &nbsp;<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"
        class="style3"></form>
</body>
</html>

Partial Class BuyoutPage
    Inherits System.Web.UI.Page

    Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub
End Class

Open in new window

Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

I'm assuming the DataList is being bound on page load.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="NewEngland.aspx.vb" Inherits="BuyoutPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">
        .style2
        {
            height: 551px;
        }
        .style3
        {
            height: 25px;
            width: 76px;
        }
    </style>
   
</head>
<body>


    <form id="form1" runat="server" class="style2">
    <div>
   
        &nbsp;<br />
         
        <br />
       
   
        <asp:DataList ID="DataList1" runat="server" DataSourceID="Boutlist"
            Height="228px" RepeatDirection="Horizontal" style="margin-top: 50px"
            Width="520px">
            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
                VerticalAlign="Top" />
            <ItemTemplate>
                Status:
                <asp:Label ID="StatusLabel" runat="server" Text='<%# Eval("Status") %>' />
                <br />
                Lease:
                <asp:Label ID="LeaseLabel" runat="server" Text='<%# Eval("Lease") %>' />
                <br />
                End_Date:
                <asp:Label ID="End_DateLabel" runat="server"
                    Text='<%# Eval("End_Date") %>' />
                <br />
                Customer_Name:
                <asp:Label ID="Customer_NameLabel" runat="server"
                    Text='<%# Eval("Customer_Name") %>' />
                <br />
                Trade_Up:
                <asp:Label ID="Trade_UpLabel" runat="server"
                    Text='<%# Eval("Trade_Up") %>' />
                <br />
                Past_Due_Invoices:
                <asp:Label ID="Past_Due_InvoicesLabel" runat="server"
                    Text='<%# Eval("Past_Due_Invoices") %>' />
                <br />
                FF_Start:
                <asp:Label ID="FF_StartLabel" runat="server" Text='<%# Eval("FF_Start") %>' />
                <br />
                FF_End:
                <asp:Label ID="FF_EndLabel" runat="server"
                    Text='<%# Eval("FF_End") %>' />
                <br />
                Fast_Forward_Past_Due:
                <asp:Label ID="Fast_Forward_Past_DueLabel" runat="server"
                    Text='<%# Eval("Fast_Forward_Past_Due") %>' />
                <br />
                <br />
            </ItemTemplate>
        </asp:DataList>
        <br />
        <asp:TextBox ID="TextBox1" runat="server" Font-Size="Small"
            Height="33px" Width="534px" BorderStyle="None" Font-Bold="True">All past due amounts need to be added to the Trade up Amount!</asp:TextBox>
   
        <br />
        <asp:TextBox ID="TextBox2" runat="server" Font-Size="Small" Width="914px"
            BorderStyle="None" Font-Bold="True">These figures are estimates and any written order will need to be accompanied by an official trade up quote from MailFinance.</asp:TextBox>
   
        <br />
        <br />
   
        <br />
   
    </div>
       
        <asp:SqlDataSource ID="Boutlist" runat="server"
            ConnectionString="<%$ ConnectionStrings:NewEnglandBO %>">
            <SelectParameters>
                <asp:QueryStringParameter Name="Lease" QueryStringField="Leasenum"
                    Type="String" />
                    <asp:QueryStringParameter Name="table" QueryStringField="Tablename"
                    Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
    &nbsp;<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"
        class="style3"></form>
</body>
</html>




Partial Public Class BuyoutPage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Boutlist.SelectCommand = "SELECT [Status],[Lease], [End Date] AS End_Date, [Customer Name] AS Customer_Name, [Trade Up] AS Trade_Up, [Past Due Invoices] AS Past_Due_Invoices, [FF Start] AS FF_Start, [FF End] AS FF_End, [Fast Forward Past Due] AS Fast_Forward_Past_Due FROM " & Request.QueryString("TableName") & " WHERE ([Lease] = @Lease)"
    End Sub

End Class

Open in new window

Anthony CardulloSystem Administrator

Author

Commented:
errors
Error      1      The server tag is not well formed.      C:\Users\acardullo.MODULAR.LOCAL\Documents\Websites\mmsweb\NewEngland.aspx      90      

Error      2      Literal expressions like '<%$ ConnectionStrings:NewEnglandBO %>' are not allowed. Use <asp:Literal runat="server" Text="<%$ ConnectionStrings:NewEnglandBO%>" /> instead.      C:\Users\acardullo.MODULAR.LOCAL\Documents\Websites\mmsweb\NewEngland.aspx      91      

Error      3      Name 'Boutlist' is not declared.      C:\Users\acardullo.MODULAR.LOCAL\Documents\Websites\mmsweb\NewEngland.aspx.vb      6      9      C:\...\mmsweb\

When I use that code, I can build and run the application without any errors.  What version of .NET are you using?
Anthony CardulloSystem Administrator

Author

Commented:
3.5
Anthony CardulloSystem Administrator

Author

Commented:
my bad.  pasted wrong.  let me test
Try this.  I ignored the Lease parameter.


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="NewEngland.aspx.vb" Inherits="BuyoutPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">
        .style2
        {
            height: 551px;
        }
        .style3
        {
            height: 25px;
            width: 76px;
        }
    </style>
   
</head>
<body>


    <form id="form1" runat="server" class="style2">
    <div>
   
        &nbsp;<br />
         
        <br />
       
   
        <asp:DataList ID="DataList1" runat="server" DataSourceID="Boutlist"
            Height="228px" RepeatDirection="Horizontal" style="margin-top: 50px"
            Width="520px">
            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
                VerticalAlign="Top" />
            <ItemTemplate>
                Status:
                <asp:Label ID="StatusLabel" runat="server" Text='<%# Eval("Status") %>' />
                <br />
                Lease:
                <asp:Label ID="LeaseLabel" runat="server" Text='<%# Eval("Lease") %>' />
                <br />
                End_Date:
                <asp:Label ID="End_DateLabel" runat="server"
                    Text='<%# Eval("End_Date") %>' />
                <br />
                Customer_Name:
                <asp:Label ID="Customer_NameLabel" runat="server"
                    Text='<%# Eval("Customer_Name") %>' />
                <br />
                Trade_Up:
                <asp:Label ID="Trade_UpLabel" runat="server"
                    Text='<%# Eval("Trade_Up") %>' />
                <br />
                Past_Due_Invoices:
                <asp:Label ID="Past_Due_InvoicesLabel" runat="server"
                    Text='<%# Eval("Past_Due_Invoices") %>' />
                <br />
                FF_Start:
                <asp:Label ID="FF_StartLabel" runat="server" Text='<%# Eval("FF_Start") %>' />
                <br />
                FF_End:
                <asp:Label ID="FF_EndLabel" runat="server"
                    Text='<%# Eval("FF_End") %>' />
                <br />
                Fast_Forward_Past_Due:
                <asp:Label ID="Fast_Forward_Past_DueLabel" runat="server"
                    Text='<%# Eval("Fast_Forward_Past_Due") %>' />
                <br />
                <br />
            </ItemTemplate>
        </asp:DataList>
        <br />
        <asp:TextBox ID="TextBox1" runat="server" Font-Size="Small"
            Height="33px" Width="534px" BorderStyle="None" Font-Bold="True">All past due amounts need to be added to the Trade up Amount!</asp:TextBox>
   
        <br />
        <asp:TextBox ID="TextBox2" runat="server" Font-Size="Small" Width="914px"
            BorderStyle="None" Font-Bold="True">These figures are estimates and any written order will need to be accompanied by an official trade up quote from MailFinance.</asp:TextBox>
   
        <br />
        <br />
   
        <br />
   
    </div>
       
        <asp:SqlDataSource ID="Boutlist" runat="server"
            ConnectionString="<%$ ConnectionStrings:NewEnglandBO %>" />
    &nbsp;<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"
        class="style3"></form>
</body>
</html>


---------------------

Partial Public Class BuyoutPage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Boutlist.SelectCommand = "SELECT [Status],[Lease], [End Date] AS End_Date, [Customer Name] AS Customer_Name, [Trade Up] AS Trade_Up, [Past Due Invoices] AS Past_Due_Invoices, [FF Start] AS FF_Start, [FF End] AS FF_End, [Fast Forward Past Due] AS Fast_Forward_Past_Due FROM " & Request.QueryString("TableName") & " WHERE ([Lease] = " & Request.QueryString("Leasenum") & ")"
    End Sub

End Class

Open in new window

Anthony CardulloSystem Administrator

Author

Commented:
that returns this error when i f5 it
Server Error in '/mmsweb' Application.
--------------------------------------------------------------------------------

Incorrect syntax near the keyword 'WHERE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Are you passing values for Leasenum and TableName in the querystring?
Anthony CardulloSystem Administrator

Author

Commented:
Yes i am. and i verified them to be valid.  the Table value i am passing is test and a valid leasenu,  value as well.
Anthony CardulloSystem Administrator

Author

Commented:
sorry  this is the error i get when i actually pass the values
Server Error in '/' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>
 

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>
 
Please modify your web.config file to show the error or run in debug mode and paste where the error is occurring.
Anthony CardulloSystem Administrator

Author

Commented:
this is the error i'm getting

this is the url im using

http://mywebsite/NewEngland.aspx?Leasenum=H041007072E?TableName=Test

Server Error in '/' Application.
--------------------------------------------------------------------------------

Incorrect syntax near the keyword 'WHERE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'WHERE'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[SqlException (0x80131904): Incorrect syntax near the keyword 'WHERE'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1950890
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846875
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
   System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
   System.Data.SqlClient.SqlDataReader.get_MetaData() +83
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +141
   System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +12
   System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +10
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +130
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +287
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1297
   System.Web.UI.WebControls.BaseDataList.GetData() +38
   System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +153
   System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +54
   System.Web.UI.WebControls.BaseDataList.DataBind() +55
   System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +60
   System.Web.UI.WebControls.BaseDataList.CreateChildControls() +69
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +44
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082
Anthony CardulloSystem Administrator

Author

Commented:
did you mean to cut this down to this?

<asp:SqlDataSource ID="Boutlist" runat="server"
            ConnectionString="<%$ ConnectionStrings:NewEnglandBO %>" />
    &nbsp;<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"
        class="style3"></form>

its not longer assigning the variables  to the querystring this way
Try this in your code file
Boutlist.SelectCommand = "SELECT [Status],[Lease], [End Date] AS End_Date, [Customer Name] AS Customer_Name, [Trade Up] AS Trade_Up, [Past Due Invoices] AS Past_Due_Invoices, [FF Start] AS FF_Start, [FF End] AS FF_End, [Fast Forward Past Due] AS Fast_Forward_Past_Due FROM " & Request.QueryString("TableName") & " WHERE [Lease] = " & Request.QueryString("Leasenum")

Open in new window

Anthony CardulloSystem Administrator

Author

Commented:
same error
Can you re-paste your code so I can make sure we're on the same page?  I'm not getting any errors.
Anthony CardulloSystem Administrator

Author

Commented:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="NewEngland.aspx.vb" Inherits="BuyoutPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">
        .style2
        {
            height: 551px;
        }
        .style3
        {
            height: 25px;
            width: 76px;
        }
    </style>
   
</head>
<body>


    <form id="form1" runat="server" class="style2">
    <div>
   
        &nbsp;<br />
         
        <br />
       
   
        <asp:DataList ID="DataList1" runat="server" DataSourceID="Boutlist"
            Height="228px" RepeatDirection="Horizontal" style="margin-top: 50px"
            Width="520px">
            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left"
                VerticalAlign="Top" />
            <ItemTemplate>
                Status:
                <asp:Label ID="StatusLabel" runat="server" Text='<%# Eval("Status") %>' />
                <br />
                Lease:
                <asp:Label ID="LeaseLabel" runat="server" Text='<%# Eval("Lease") %>' />
                <br />
                End_Date:
                <asp:Label ID="End_DateLabel" runat="server"
                    Text='<%# Eval("End_Date") %>' />
                <br />
                Customer_Name:
                <asp:Label ID="Customer_NameLabel" runat="server"
                    Text='<%# Eval("Customer_Name") %>' />
                <br />
                Trade_Up:
                <asp:Label ID="Trade_UpLabel" runat="server"
                    Text='<%# Eval("Trade_Up") %>' />
                <br />
                Past_Due_Invoices:
                <asp:Label ID="Past_Due_InvoicesLabel" runat="server"
                    Text='<%# Eval("Past_Due_Invoices") %>' />
                <br />
                FF_Start:
                <asp:Label ID="FF_StartLabel" runat="server" Text='<%# Eval("FF_Start") %>' />
                <br />
                FF_End:
                <asp:Label ID="FF_EndLabel" runat="server"
                    Text='<%# Eval("FF_End") %>' />
                <br />
                Fast_Forward_Past_Due:
                <asp:Label ID="Fast_Forward_Past_DueLabel" runat="server"
                    Text='<%# Eval("Fast_Forward_Past_Due") %>' />
                <br />
                <br />
            </ItemTemplate>
        </asp:DataList>
        <br />
        <asp:TextBox ID="TextBox1" runat="server" Font-Size="Small"
            Height="33px" Width="534px" BorderStyle="None" Font-Bold="True">All past due amounts need to be added to the Trade up Amount!</asp:TextBox>
   
        <br />
        <asp:TextBox ID="TextBox2" runat="server" Font-Size="Small" Width="914px"
            BorderStyle="None" Font-Bold="True">These figures are estimates and any written order will need to be accompanied by an official trade up quote from MailFinance.</asp:TextBox>
   
        <br />
        <br />
   
        <br />
   
    </div>
       
        <asp:SqlDataSource ID="Boutlist" runat="server"
            ConnectionString="<%$ ConnectionStrings:NewEnglandBO %>" />
    &nbsp;<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"
        class="style3"></form>
</body>
</html>

My back code




Partial Public Class BuyoutPage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Boutlist.SelectCommand = "SELECT [Status],[Lease], [End Date] AS End_Date, [Customer Name] AS Customer_Name, [Trade Up] AS Trade_Up, [Past Due Invoices] AS Past_Due_Invoices, [FF Start] AS FF_Start, [FF End] AS FF_End, [Fast Forward Past Due] AS Fast_Forward_Past_Due FROM " & Request.QueryString("TableName") & " WHERE [Lease] = " & Request.QueryString("Leasenum")
    End Sub

End Class

Open in new window

What data type is Lease?  You may have to modify to include apostrophes.  Perhaps I incorrectly assumed it was an integer.
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Boutlist.SelectCommand = "SELECT [Status],[Lease], [End Date] AS End_Date, [Customer Name] AS Customer_Name, [Trade Up] AS Trade_Up, [Past Due Invoices] AS Past_Due_Invoices, [FF Start] AS FF_Start, [FF End] AS FF_End, [Fast Forward Past Due] AS Fast_Forward_Past_Due FROM " & Request.QueryString("TableName") & " WHERE [Lease] = '" & Request.QueryString("Leasenum") & "'"
    End Sub

Open in new window

Anthony CardulloSystem Administrator

Author

Commented:
they are both strings
What data type is the Lease column in your table?
Anthony CardulloSystem Administrator

Author

Commented:
nvarchar

the problem was wiht the url string.   it needed to be http://myweb?attrib1=Value1&attrib2=value2

it needed the ampersand and not a second ?
That would do it.
Anthony CardulloSystem Administrator

Author

Commented:
ok  thanks for all the help.  got ti working now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial