|
Subject:
|
Input string was not in a correct format
|
|
Posted By:
|
dgood9
|
Post Date:
|
1/5/2007 4:24:11 PM
|
|
I am using a Gridview to return warehouse locations. When one is selected, I have another gridview calling a stored procedure to find empty locations nearby. The warehouse ID is 4 characters. It works fine if the warehouse ID is numeric, but not if I have characters in the warehouse ID. Has anyone seen this before?
|
|
Reply By:
|
planoie
|
Reply Date:
|
1/5/2007 5:00:41 PM
|
You are going to have to provide more details than this.
What are you trying to DO with the ID value? What is the error you are getting?
Given that you are calling a DB query I will venture a guess:
I have seen cases where you call a DB query with a value that should actually be characters, but you don't wrap it in quotes. It will work when the value is just numbers. Somehow the DB server can interpret it correctly. But as soon as you throw a character in the mix, it chokes because it doesn't interpret the sequence of characters as a number any more but as a string.
Check your query construction and verify the ID being passed is inside of quotes.
-Peter
|
|
Reply By:
|
dgood9
|
Reply Date:
|
1/8/2007 12:26:17 PM
|
Maybe I am letting the Visual Web Developer do too much for me. I have a GridView <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="WHSE_ID,WHSE_ZONE_ID,WHSE_ROW_ID,WHSE_SLOT_NUMBER,WHSE_TIER,WHSE_BIN_POSITION" DataSourceID="SqlDS_Existing" ForeColor="#333333" GridLines="None" Width="500px"> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <Columns> <asp:BoundField DataField="WHSE_ID" HeaderText="Whse" ReadOnly="True" SortExpression="WHSE_ID"> <HeaderStyle Font-Names="Arial" HorizontalAlign="Left" /> </asp:BoundField> <asp:BoundField DataField="WHSE_ZONE_ID" HeaderText="Zone" ReadOnly="True" SortExpression="WHSE_ZONE_ID"> <HeaderStyle Font-Names="Arial" HorizontalAlign="Left" /> </asp:BoundField> <asp:BoundField DataField="WHSE_ROW_ID" HeaderText="Row" ReadOnly="True" SortExpression="WHSE_ROW_ID"> <HeaderStyle Font-Names="Arial" HorizontalAlign="Left" /> </asp:BoundField> <asp:BoundField DataField="WHSE_SLOT_NUMBER" HeaderText="Slot" ReadOnly="True" SortExpression="WHSE_SLOT_NUMBER"> <HeaderStyle Font-Names="Arial" HorizontalAlign="Left" /> </asp:BoundField> <asp:BoundField DataField="WHSE_TIER" HeaderText="Tier" ReadOnly="True" SortExpression="WHSE_TIER"> <HeaderStyle Font-Names="Arial" HorizontalAlign="Left" /> </asp:BoundField> <asp:BoundField DataField="WHSE_BIN_POSITION" HeaderText="Position" ReadOnly="True" SortExpression="WHSE_BIN_POSITION" /> <asp:CommandField ShowSelectButton="True" /> using this SQLDataSource <asp:SqlDataSource ID="SqlDS_Existing" runat="server" ConnectionString="<%$ ConnectionStrings:GW_WMSConnectionString %>" SelectCommand="GW_GET_EXISTING_LOCATIONS" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="LblContainerID" Name="Container_ID" PropertyName="Text" Type="Int32" /> <asp:ControlParameter ControlID="Label5" Name="Whse_ID" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource> The user selects a row in this Gridview. That location is used as the input to another Gridview whose purpose is to return empty location near the selected location. <asp:GridView ID="GridView5" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDS_GetNear" ForeColor="#333333" GridLines="None"> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="WHSE_ID" HeaderText="WHSE_ID" SortExpression="WHSE_ID" /> <asp:BoundField DataField="WHSE_ZONE_ID" HeaderText="WHSE_ZONE_ID" SortExpression="WHSE_ZONE_ID" /> <asp:BoundField DataField="WHSE_ROW_ID" HeaderText="WHSE_ROW_ID" SortExpression="WHSE_ROW_ID" /> <asp:BoundField DataField="WHSE_SLOT_NUMBER" HeaderText="WHSE_SLOT_NUMBER" SortExpression="WHSE_SLOT_NUMBER" /> <asp:BoundField DataField="WHSE_TIER" HeaderText="WHSE_TIER" SortExpression="WHSE_TIER" /> <asp:BoundField DataField="WHSE_BIN_POSITION" HeaderText="WHSE_BIN_POSITION" SortExpression="WHSE_BIN_POSITION" /> </Columns> <RowStyle BackColor="#EFF3FB" /> <EditRowStyle BackColor="#2461BF" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> SQLDataSource <asp:SqlDataSource ID="SqlDS_GetNear" runat="server" ConnectionString="<%$ ConnectionStrings:GW_WMSConnectionString %>" SelectCommand="GW_GET_EMPTY_LOCATIONS" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="GridView2" Name="Whse_ID" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="GridView2" Name="Whse_Zone_ID" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="GridView2" Name="Whse_Row_ID" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="GridView2" Name="Whse_Slot_Number" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="GridView2" Name="Whse_Tier" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="GridView2" Name="Whse_Bin_Position" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:SqlDataSource>
The Table definition has the Warehouse as a nchar(4) field. It works fine for numeric data but not characters. I am letting the controls do most of the work, it just does not work when the warehouse has characters like 'TEST' instead of a number. The input values for the stored procedure used by "GridView5" are pulled from the control "GridView2", no manipulation on my part..
|