sqldatasource select where clause .. unexpected behavior???

J

jobs

I have a gridview that times when selecting from specific table when I
try to when I add a where clause. Even when I'm only seleting Top 1
which comes right back at the command line.

I test the below code with two different tables in the datasource for
the gridview, one works the other times out. If I perform the same
query in sql server manually both tables work fine and fast. if I hard
code the where clause in the asp.net the code works fine.

the difference between the tables is that the problem one has Processid
(the select param) as a clustered key index.

If I remove or hard code the where clause the code works fine.

Wondering, is asp.net doing something special when my where clause has
the key in it?

something different about processid is that it's about 30 char long and
contains dashes '-'

<%@ Page Language="VB" AutoEventWireup="false"
MasterPageFile="~/Default.master" Title="Errors" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
runat="Server">
<asp:DropDownList ID="BatchList" runat="server"
DataSourceID="ProcesslDataSource"
DataTextField="ProcessId" DataValueField="ProcessId"
SkinID="DropDownList" AutoPostBack="true">
</asp:DropDownList>
<asp:SqlDataSource ID="ProcesslDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:xxConnectionString %>"
SelectCommand="SELECT Rtrim([ProcessId]) as ProcessId
FROM [x1s_vw]">
</asp:SqlDataSource>


<asp:GridView ID="EntelGridView" runat="server"
AutoGenerateColumns="False" DataSourceID="EntelDataSource"
SkinID="GridView">
<Columns>
<asp:BoundField DataField="ProcessId"/>
</Columns>
</asp:GridView>
<br />
<asp:SqlDataSource ID="xxlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:x2ConnectionString %>"
selectCommand="select TOP 1 * from x2 where ProcessId =
@ProcessId">
<SelectParameters>
<asp:ControlParameter ControlID="BatchList"
Name="ProcessId" PropertyName="SelectedValue" type=string/>
</SelectParameters>
</asp:SqlDataSource>
<br />

</asp:Content>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top