locked
How to run this in query in SqlDatasource RRS feed

  • Question

  • User-80134705 posted

    <asp:SqlDataSource ID="dsCustomer" runat="server"
    ConnectionString="<%$ ConnectionStrings:DataAccessStart1%>"

    SelectCommand="SELECT DISTINCT CustomerCode,CustomerName,CustomerPhone from CustomerMaster where CustomerCode in(114,11,19,232,145,241)">

    </asp:SqlDataSource>

    Please give the answer

    Thursday, August 11, 2016 7:31 AM

Answers

  • User-2057865890 posted

    Hi Hrishik,

    You can try to use what I mentioned below.

    It is just a demo code to give you an example you can also modify it by yourself.

    <%@ Page language="C#" %>
    
    <!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>ASP.NET Example</title>
    </head>
    <body>
        <form id="form1" runat="server">
          <asp:SqlDataSource
              Id="dsCustomer"
              runat="server"
              DataSourceMode="DataReader"
              ConnectionString="<%$ ConnectionStrings:DataAccessStart1%>"           SelectCommand="SELECT DISTINCT CustomerCode,CustomerName,CustomerPhone from CustomerMaster where CustomerCode in(114,11,19,232,145,241)">
          </asp:SqlDataSource>
    
          <asp:ListBox
              id="ListBox1"
              runat="server"
              DataTextField="LastName"
              DataSourceID="SqlDataSource1">
          </asp:ListBox>
    
        </form>
      </body>
    </html>
    

    Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 12, 2016 9:22 AM

All replies

  • User702547207 posted

    Hi,

    You can refer the below link.

    http://flylib.com/books/en/3.444.1.77/1/

    Thursday, August 11, 2016 7:49 AM
  • User-2057865890 posted

    Hi Hrishik,

    You can try to use what I mentioned below.

    It is just a demo code to give you an example you can also modify it by yourself.

    <%@ Page language="C#" %>
    
    <!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>ASP.NET Example</title>
    </head>
    <body>
        <form id="form1" runat="server">
          <asp:SqlDataSource
              Id="dsCustomer"
              runat="server"
              DataSourceMode="DataReader"
              ConnectionString="<%$ ConnectionStrings:DataAccessStart1%>"           SelectCommand="SELECT DISTINCT CustomerCode,CustomerName,CustomerPhone from CustomerMaster where CustomerCode in(114,11,19,232,145,241)">
          </asp:SqlDataSource>
    
          <asp:ListBox
              id="ListBox1"
              runat="server"
              DataTextField="LastName"
              DataSourceID="SqlDataSource1">
          </asp:ListBox>
    
        </form>
      </body>
    </html>
    

    Regards,

    Chris

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 12, 2016 9:22 AM