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!)