G
Guest
I have a stored procedure that takes three input parameters and returns a
single record result set. The stored procedure is declare as follows:
p_getTaxAmount (@ZipCodeDtlId uniqueidentifier, @CategoryID
uniqueidentifier, @SalesAmount decimal(17,8))
I have a windows form where the user enters the zip code, category, and
sales amount. I need to know how to capture the value in the sales amount
text box and send it as a parameter to the stored procedure. I'm very close
but I don't know how to convert the string from the text box to a decimal
value. I keep getting an error message stating "Input string was not in
correct format". My conversion statement is shown below. How do I send the
parameter to the stored procedure so the proc will run with the proper input
parameters?
string strSalesAmt = this.tboxAmount.ToString();
decimal SalesAmount = System.Convert.ToDecimal(strSalesAmt);
this.sqlConnection1.ConnectionString
=ConnectionString.CompanyConnectionString;
this.sqlSelectCommand1.CommandText = "[p_getTaxAmount]";
this.sqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure;
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
false, ((System.Byte)(0)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@ZipCodeDtlID",
System.Data.SqlDbType.UniqueIdentifier));
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@CategoryID",
System.Data.SqlDbType.UniqueIdentifier));
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@SalesAmount",
System.Data.SqlDbType.Decimal));
this.sqlSelectCommand1.Parameters["@ZipCodeDtlID"].Value = ZipCodeDtlId;
this.sqlSelectCommand1.Parameters["@CategoryID"].Value = CategoryId;
this.sqlSelectCommand1.Parameters["@SalesAmount"].Value = SalesAmount;
single record result set. The stored procedure is declare as follows:
p_getTaxAmount (@ZipCodeDtlId uniqueidentifier, @CategoryID
uniqueidentifier, @SalesAmount decimal(17,8))
I have a windows form where the user enters the zip code, category, and
sales amount. I need to know how to capture the value in the sales amount
text box and send it as a parameter to the stored procedure. I'm very close
but I don't know how to convert the string from the text box to a decimal
value. I keep getting an error message stating "Input string was not in
correct format". My conversion statement is shown below. How do I send the
parameter to the stored procedure so the proc will run with the proper input
parameters?
string strSalesAmt = this.tboxAmount.ToString();
decimal SalesAmount = System.Convert.ToDecimal(strSalesAmt);
this.sqlConnection1.ConnectionString
=ConnectionString.CompanyConnectionString;
this.sqlSelectCommand1.CommandText = "[p_getTaxAmount]";
this.sqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure;
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
false, ((System.Byte)(0)), ((System.Byte)(0)), "",
System.Data.DataRowVersion.Current, null));
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@ZipCodeDtlID",
System.Data.SqlDbType.UniqueIdentifier));
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@CategoryID",
System.Data.SqlDbType.UniqueIdentifier));
this.sqlSelectCommand1.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@SalesAmount",
System.Data.SqlDbType.Decimal));
this.sqlSelectCommand1.Parameters["@ZipCodeDtlID"].Value = ZipCodeDtlId;
this.sqlSelectCommand1.Parameters["@CategoryID"].Value = CategoryId;
this.sqlSelectCommand1.Parameters["@SalesAmount"].Value = SalesAmount;