ruedi
ruedi

Reputation: 5555

decimal value from db displayed in textbox

I have a stored procedure that calculates me a decimal(18,1) datatype value. I want put that in a textbox in my vb.net programm via

Dim conn As New SqlConnection("Data Source=a\SQLEXPRESS;Initial Catalog=b;Integrated Security=TRUE")
Dim cmd As SqlCommand = New SqlCommand("dbo.c", conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@d", SqlDbType.Decimal)
cmd.Parameters(@d").Direction = ParameterDirection.Output

I thought setting SqlDbType.Decimal would give me the decimal into my textbox it doesnt work i only get an integer (original value in my database is 2.5, value in my textbox is 3).

During my search for a solution if found this

Dim parameter As New SqlParameter("@Price", SqlDbType.Decimal)
With parameter
.Value = 3.1416
.Precision = 8
.Scale = 4
End With

But i cannot apply this since i have a output parameter. I switched "@price" with my parameter but nothing is displayed except for "Label1". I really need my decimal displayed in my textbox and need help with it.

Upvotes: 2

Views: 715

Answers (1)

ruedi
ruedi

Reputation: 5555

i just found the answer. i changed SqlDbType.decimal to SqlDbType.Float and it works.

Upvotes: 2

Related Questions