Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2007, 05:24 PM
Registered User
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Input string was not in a correct format

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?
 
Old January 5th, 2007, 06:00 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
 
Old January 8th, 2007, 01:26 PM
Registered User
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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,WHS E_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..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Input string was not in a correct format Dwizz VB.NET 2002/2003 Basics 8 April 29th, 2010 05:56 AM
Input string was not in a correct format. Silfverduk VB.NET 2002/2003 Basics 1 May 20th, 2006 04:58 AM
input string was not in a correct format kunal.net VS.NET 2002/2003 1 October 11th, 2005 12:18 AM
Input string was not in a correct format Dwizz VB.NET 2002/2003 Basics 2 April 4th, 2005 11:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.