Reputation: 21
I have an application that is supposed to take a decimal input, push into a stored procedure and return a char value for use in the application.
For some reason, all of my other stored procedures seem to be working fine, however this one particular stored procedure is not working at all.
Originally, the input was in the form of a dropdown list, however the values in the list were incorrect.
For example: 0.975 in the SQL Server table would show up as 1.000 in the drop down list. 1.025 somehow became 1.050. 1.075 became 2.000
So I tossed out the drop down list in favor of a text box. I still am not receiving proper return values. Actually, I am not getting any values back at all.
Here is my code:
Form:
<asp:Label ID="Label2" runat="server" Text="Select RZD: "></asp:Label>
<asp:TextBox ID="rzdTB" runat="server"></asp:TextBox>
<asp:Label ID="rzdFSLabel" runat="server" Text="Label"></asp:Label>
Code behind:
fileNameGenerator fNG = new fileNameGenerator();
fNG.rzd = Convert.ToDouble(rzdTB.Text);
fNG.fileGenerator();
rzdFSLabel.Text = fNG.rzdfsOUT;
Label13.Text = fNG.bcfsOUT + fNG.rzdfsOUT + fNG.anglefsOUT + fNG.powerfsOUT;
lBO.fileName = fNG.bcfsOUT + fNG.rzdfsOUT + fNG.anglefsOUT + fNG.powerfsOUT;
fileNameGenerator()
//declare rzd variable - convert to double
//declare rzdSymbol as the output
c2.Parameters.AddWithValue("@rzd", SqlDbType.Float).Value =rzd;
SqlParameter rzdSymbol = new SqlParameter("@rzdSymbol", SqlDbType.VarChar);
rzdSymbol.Size = 2;
rzdSymbol.Direction = ParameterDirection.Output;
c2.Parameters.Add(rzdSymbol);
//open the connection string and execute the stored procedures
conn.Open();
c1.ExecuteNonQuery();
c2.ExecuteNonQuery();
c3.ExecuteNonQuery();
c4.ExecuteNonQuery();
conn.Close();
bcfsOUT = c1.Parameters["@bcFS"].Value.ToString();
//string sdfsOUT to label2
rzdfsOUT = c2.Parameters["@rzdSymbol"].Value.ToString();
Stored procedure:
ALTER PROCEDURE dbo.getRZDSymbol
(
@rzd decimal(10,5),
@rzdSymbol varchar(2) OUTPUT
)
AS
SET NOCOUNT ON
SELECT @rzdSymbol = rzdSymbol
FROM fileSymbolTable
WHERE rzd = @rzd
Upvotes: 1
Views: 78
Reputation: 21
I feel foolish, but the answer was rather simple.
I had a deep look at the c2 parameter while debugging. I kept seeing "FLOAT" as the rzd datatype. That seemed rather odd so I began investigating where exactly I was pulling data from. TO make matters more confusing, I have two databases on my local machine and one on a development server on our network. I believed I was still hooked into the local machine, but it turns I was pulling from the networked db.
Drop the table on the network, re-imported from the local machine and BAM!
All of a sudden it works. Imagine that...
Very sorry, but thank you all for the help.
Upvotes: 1