Input string was not in a correct format.error
Input string was not in a correct format.
on the line " DBCommand.ExecuteNonQuery()"
Any ideas what 'm doing wrong could it be the FLOAT and Money datatypes
Thanks
'DBConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnStr"))
Dim DBCommand As SqlCommand = New SqlCommand("prMonthlyTargetsUpdateRecord", myConnection)
'Dim DBCommand As SqlCommand = New SqlCommand("UPDATE CMRC_Users SET FullName = @Name, EmailAddress = @Email, Password = @Pwd WHERE UserID = @UserID", DBConnection)
DBCommand.CommandType = CommandType.StoredProcedure
'DBCommand.Parameters.Add(New SqlParameter("@UserID", location.Text))
DBCommand.Parameters.Add(New SqlParameter("@year", SqlDbType.Int, 4)).Value = yr.text
DBCommand.Parameters.Add(New SqlParameter("@month", SqlDbType.Int, 4)).Value = mnth.text
DBCommand.Parameters.Add(New SqlParameter("@territory_code", SqlDbType.VarChar, 10)).Value = ter_code.text
DBCommand.Parameters.Add(New SqlParameter("@GP_target", SqlDbType.Money, 8)).Value = gp_target.text
DBCommand.Parameters.Add(New SqlParameter("@New_Connections_target", SqlDbType.Int, 4)).Value = conn_target.text
DBCommand.Parameters.Add(New SqlParameter("@Upgrade_Connections_target", SqlDbType.Int, 4)).Value = uograde_conn_target.text
DBCommand.Parameters.Add(New SqlParameter("@FTE", SqlDbType.Float, 8)).Value = fte.text
DBCommand.Parameters.Add(New SqlParameter("@PlansGT80", SqlDbType.Int, 4)).Value = plans.Text
DBCommand.Parameters.Add(New SqlParameter("@Foxtel", SqlDbType.Int, 4)).Value = foxtel.text
DBCommand.Parameters.Add(New SqlParameter("@Broadband", SqlDbType.Int, 4)).Value = broadband.text
DBCommand.Parameters.Add(New SqlParameter("@PrePaidPhones", SqlDbType.Int, 4)).Value = PrePaidPhones.text
DBCommand.Parameters.Add(New SqlParameter("@PrePaidRecharge", SqlDbType.Int, 4)).Value = PrePaidRecharge.text
DBCommand.Parameters.Add(New SqlParameter("@OutrightPhones", SqlDbType.Int, 4)).Value = OutrightPhones.text
DBCommand.Parameters.Add(New SqlParameter("@HandsetInsurance", SqlDbType.Int, 4)).Value = HandsetInsurance.text
DBCommand.Parameters.Add(New SqlParameter("@GenuineAccessory", SqlDbType.Int, 4)).Value = GenuineAccessory.text
DBCommand.Parameters.Add(New SqlParameter("@EBIT", SqlDbType.Float, 8)).Value = EBIT.Text
DBCommand.Parameters.Add(New SqlParameter("@StoreType", SqlDbType.VarChar, 10)).Value = "rote"
DBCommand.Parameters.Add(New SqlParameter("@StoreAtRisk", SqlDbType.Float, 8)).Value = StoreAtRisk.Text
myConnection.Open()
DBCommand.ExecuteNonQuery()
myConnection.Close()
MyDataGrid.EditItemIndex = -1
MyDataGrid.DataBind()
GetData()
My Stor_proc is:-
@year int,
@month int,
@territory_code varchar(10),
@GP_target money,
@New_Connections_target int,
@Upgrade_Connections_target int,
@FTE float,
@PlansGT80 int,
@Foxtel int,
@Broadband int,
@PrePaidPhones int,
@PrePaidRecharge int,
@OutrightPhones int,
@HandsetInsurance int,
@GenuineAccessory int,
@EBIT float,
@StoreType varchar(10),
@StoreAtRisk float,
@Status varchar(200) OUTPUT
AS
-- Check if entry already exits
if not exists (Select 1
From dbo.MonthlyTargetsBak mt
Where mt.theyear = @year and mt.TheMonth = @month and mt.Territory_Code = @Territory_Code)
begin
set @Status = 'Entry does not exist to update'
return
end
if not exists (Select 1
From dbo.Location
Where Territory_Code = @Territory_Code)
begin
set @Status = 'Location Not Found'
return
end
update MonthlyTargetsBak
set GP_target = @GP_target,
New_Connections_target = @New_Connections_target,
Upgrade_Connections_target = @Upgrade_Connections_target,
FTE = @FTE,
PlansGT80 = @PlansGT80,
Foxtel = @Foxtel,
Broadband = @Broadband,
PrePaidPhones = @PrePaidPhones,
PrePaidRecharge = @PrePaidRecharge,
OutrightPhones = @OutrightPhones,
HandsetInsurance = @HandsetInsurance,
GenuineAccessory = @GenuineAccessory,
EBIT = @EBIT,
StoreType = @StoreType,
StoreAtRisk = @StoreAtRisk
where theyear = @year
and TheMonth = @month
and Territory_Code = @Territory_Code
print cast(@@rowcount as varchar)
set @Status = 'Record Updated'
return @@rowcount
GO

