if you are returning a single field, use ExecuteScalar() to get it and
assign the value to your textbox:
sub Page_Load
someTextBox.Text = GetProductAmount(3).ToString()
end sub
public shared function GetProductAmount(productId as integer) as decimal
dim connection as new sqlconnection(connection_String)
dim command as new sqlcommad("SELECT Amount from Price where Id =@id",
connection)
command.parameters.add("@Id", SqlDbType.Int).Value = productId
try
connection.open()
return cdec(command.ExecuteScalar())
finally
connection.dispose()
command.dispoe()
end try
end function
of course you might wanna check for null if that's possible:
dim o as object = command.ExecuteScalar()
if not o is nothing andalso not o is DbNull.Value then
return cdec(o)
end if
return 0.0
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"neil_pat" <ne*****@discussions.microsoft.com> wrote in message
news:2C**********************************@microsof t.com...
I have a stored procedure which returns a decimal field from a table and i
want my asp.net page to read in the result and then diplay it in a textbox
or a label.
What is the best way to do this?