Why don't you just set it to true/false instead of "true"/"fale"
ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
intCurrentMonthCollections
and why is that var prefixed with "int" if it's a bool? Prefixing isn't
really used much anymore anyways..
Karl
--
http://www.openmymind.net/ http://www.fuelindustries.com/
"dba123" <dba123@discussions.microsoft.com> wrote in message
news:460D12E2-2F3F-446F-BBA3-CA80CDAE09F1@microsoft.com...[color=blue]
> Ok, I changed these since SQL Server bit is expecting true or false, not 1
> or
> zero...that would be for an integer db field:
>
> If intCurrentMonthCollections = True Then
>
> ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 1
> Else
>
> ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
> End If
>
> to
>
> If intCurrentMonthCollections = True Then
>
> ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
> "true"
> Else
>
> ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
> "false"
> End If
>
> The error goes away but it's still not updating those bit fields in my
> table
>
>
> --
> dba123
>
>
> "dba123" wrote:
>[color=green]
>> String was not recognized as a valid Boolean
>>
>> For Line: ds_dashboard.Update() in my update function
>>
>>
>> My SQLDataSource:
>> -------------------------
>>
>> <asp:SqlDataSource
>> ID="ds_dashboard"
>> runat="server"
>> ConnectionString="<%$ ConnectionStrings:DashboardConn %>"
>> SelectCommand="aspx_Get_Customer_DashboardGraphs"
>> SelectCommandType="StoredProcedure"
>> UpdateCommand="aspx_Update_Customer_DashboardGraph s"
>> UpdateCommandType="StoredProcedure"[color=darkred]
>> >[/color]
>> <UpdateParameters>
>> <asp:Parameter Name="CustomerID" Type="Int32" />
>> <asp:Parameter Name="Budget" Type="Int32" />
>> <asp:Parameter Name="CurrentMonthCollections"
>> Type="Boolean" />
>> <asp:Parameter Name="RevenueByMonth" Type="Boolean"
>> />
>> <asp:Parameter Name="PDCsCCsMonthly" Type="Boolean"
>> />
>> <asp:Parameter Name="RevenueByClient" Type="Boolean"
>> />
>>
>> </UpdateParameters>
>>
>> </asp:SqlDataSource>
>>
>>
>> My GridView:
>> ---------------------
>>
>> <asp:GridView
>> ID="gv_dashboard"
>> runat="server"
>> AutoGenerateColumns="False"
>> DataSourceID="ds_dashboard"
>> CellPadding="4"
>> ForeColor="#333333"
>> ShowFooter="True"
>> GridLines="None"
>> CssClass="FormatFont">
>>
>> <Columns>
>> <asp:TemplateField HeaderText="Cust #"
>> SortExpression="CustomerID">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:Label runat="server" id="lblCustomerID"
>> Text='<%# Bind("Customer") %>' />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="Budget"
>> SortExpression="Name"
>> ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
>> <ItemTemplate>
>> <asp:TextBox width="55px" MaxLength="10"
>> ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="Current Month Collections"
>> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:checkbox runat="server"
>> Id="chbx_CurrentMonthCollections" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="Revenue By Month"
>> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:checkbox runat="server"
>> Id="chbx_RevenueByMonth" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="PDCs & CCS Monthly"
>> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:checkbox runat="server"
>> Id="chbx_PDCsCCsMonthly" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="Revenue By Client"
>> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:checkbox runat="server"
>> Id="chbx_RevenueByClient" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> </Columns>
>>
>> <FooterStyle BackColor="#5D7B9D" Font-Bold="True"
>> ForeColor="White" />
>> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
>> <EditRowStyle BackColor="#DDDDDD" />
>> <SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
>> ForeColor="#333333" />
>> <PagerStyle BackColor="#284775" ForeColor="White"
>> HorizontalAlign="Center" />
>> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
>> ForeColor="White" />
>> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
>> </asp:GridView>
>>
>>
>> My Update Command (Stored Procedure):
>> --------------------------------------------------
>>
>> ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]
>>
>> @CustomerID bigint,
>> @Budget int,
>> @CurrentMonthCollections bit,
>> @RevenueByMonth bit,
>> @PDCsCCsMonthly bit,
>> @RevenueByClient bit
>>
>> AS
>> BEGIN
>>
>> UPDATE dbo.Customer_DashboardGraphs
>> SET Budget = @Budget,
>> CurrentMonthCollections = @CurrentMonthCollections,
>> RevenueByMonth = @RevenueByMonth,
>> PDCsCCsMonthly = @PDCsCCsMonthly,
>> RevenueByClient = @RevenueByClient
>> WHERE Customer_DashboardGraphs.Customer = @CustomerID
>> END
>>
>>
>> My Table Schema:
>> -----------------------
>>
>> CREATE TABLE [dbo].[Customer_DashboardGraphs](
>> [Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
>> [DashboardGraphID] [bit] NULL,
>> [CurrentMonthCollections] [bit] NULL,
>> [RevenueByMonth] [bit] NULL,
>> [PDCsCCsMonthly] [bit] NULL,
>> [RevenueByClient] [bit] NULL,
>> [Budget] [int] NULL
>> ) ON [PRIMARY]
>> Stack Trace:
>>
>> String was not recognized as a valid Boolean.
>> 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.FormatException: String was not recognized as a
>> valid Boolean.
>>
>> Source Error:
>>
>>
>> Line 53:
>> ds_dashboard.UpdateParameters("Budget").DefaultVal ue = intBudget
>> Line 54:
>> Line 55: ds_dashboard.Update()
>> Line 56: End If
>> Line 57: Next
>>
>>
>> Source File:
>> Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboar d\index.aspx.vb
>> Line: 55
>>
>>
>> Stack Trace:
>> ------------------
>>
>> [FormatException: String was not recognized as a valid Boolean.]
>> System.Boolean.Parse(String value) +2709172
>> System.String.System.IConvertible.ToBoolean(IForma tProvider provider)
>> +12
>> System.Convert.ChangeType(Object value, TypeCode typeCode,
>> IFormatProvider provider) +98
>> System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String
>> defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
>> ignoreNullableTypeChanges) +257
>> System.Web.UI.WebControls.Parameter.get_ParameterV alue() +91
>> System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext
>> context, Control control) +282
>>
>> System.Web.UI.WebControls.SqlDataSourceView.Initia lizeParameters(DbCommand
>> command, ParameterCollection parameters, IDictionary exclusionList) +344
>> System.Web.UI.WebControls.SqlDataSourceView.Execut eUpdate(IDictionary
>> keys, IDictionary values, IDictionary oldValues) +449
>> System.Web.UI.WebControls.SqlDataSourceView.Update (IDictionary keys,
>> IDictionary values, IDictionary oldValues) +37
>> System.Web.UI.WebControls.SqlDataSource.Update() +42
>> dashboard._Default.UpdateCustomer_DashboardGraphs( Object sender,
>> EventArgs e) in
>> Y:\inetpub\wwwroot\sss\webapps\dashboard\dashboard \index.aspx.vb:55
>> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
>> System.Web.UI.WebControls.Button.RaisePostBackEven t(String
>> eventArgument)
>> +116
>>
>> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
>> eventArgument) +31
>> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
>> sourceControl, String eventArgument) +32
>> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
>> +72
>> System.Web.UI.Page.ProcessRequestMain(Boolean
>> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
>> +3837
>>
>>
>> --
>> dba123
>>
>>
>> "Karl Seguin [MVP]" wrote:
>>[color=darkred]
>> > which line is the error on?
>> >
>> > Karl
>> >
>> > --
>> >
http://www.openmymind.net/
>> >
>> >
>> >
>> > "dba123" <dba123@discussions.microsoft.com> wrote in message
>> > news:0FCAE9F2-E68A-4794-9A68-BAF5877BA533@microsoft.com...
>> > > Why am I getting this error for Budget?
>> > >
>> > > Error: An exception of type 'System.FormatException' occurred in
>> > > mscorlib.dll but was not handled in user code
>> > >
>> > > Additional information: String was not recognized as a valid Boolean.
>> > >
>> > >
>> > > Public Sub UpdateCustomer_DashboardGraphs(ByVal sender As Object,
>> > > ByVal
>> > > e As System.EventArgs)
>> > > For Each gvr As GridViewRow In gv_dashboard.Rows
>> > > If gvr.RowType = DataControlRowType.DataRow Then
>> > >
>> > > '//--IDs
>> > >
>> > > Dim intCustomerID As String =
>> > > CType(gvr.FindControl("lblCustomerID"), Label).Text.Trim()
>> > >
>> > > '//--Textboxes
>> > > Dim intBudget As Integer
>> > > Try
>> > > intBudget =
>> > > CType(CType(gvr.FindControl("txtBudget"),
>> > > TextBox).Text.Trim(), Int32)
>> > > Catch
>> > > intBudget = CType(0, Int32)
>> > > End Try
>> > >
>> > > '//--Checkboxes
>> > > Dim intCurrentMonthCollections As Boolean =
>> > > CType(gvr.FindControl("chbx_CurrentMonthCollection s"),
>> > > CheckBox).Checked
>> > > Dim intRevenueByMonth As Boolean =
>> > > CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
>> > > Dim intPDCsCCsMonthly As Boolean =
>> > > CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
>> > > Dim intRevenueByClient As Boolean =
>> > > CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked
>> > >
>> > > '//--Assign UpdateParameters
>> > > If intCurrentMonthCollections = True Then
>> > >
>> > > ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue
>> > > = 1
>> > > Else
>> > >
>> > > ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue
>> > > = 0
>> > > End If
>> > > ...
>> > >
>> > > ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
>> > > intBudget
>> > >
>> > > ds_dashboard.Update()
>> > > End If
>> > > Next
>> > > End Sub
>> > > --
>> > > dba123
>> >
>> >
>> >[/color][/color][/color]