<st****@gmail.comwrote in message
news:8c**********************************@s8g2000p rg.googlegroups.com...
On 10 Jan, 15:34, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
><sta...@gmail.comwrote in message
news:29**********************************@l1g2000 hsa.googlegroups.com...
>lblBudget.Text =
Convert.ToDecimal(Generic_database_functions.GetV alue("SELECT
ISNULL(Sum(Budget), 0) FROM vwPROJECTForecast")).ToString("#.##0")
Thank you for the help. Unfortunately I receive error message: "Input
string was not in a correct format".
What datatype does GetValue return...?
It returns a string and it looks like this:
Shared Function GetValue(ByVal strSP As String)
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlCommand(strSP, myConnection)
myConnection.Open()
Dim strValue As String = myCommand.ExecuteScalar().ToString()
myConnection.Close()
Return strValue
End Function
OK, then. Please try the following and tell me where it fails:
Dim strGetValue As String
strGetValue = Generic_database_functions.GetValue("SELECT
ISNULL(Sum(Budget), 0) FROM vwPROJECTForecast")
Dim decValue As Decimal
decValue = Convert.ToDecimal(strGetValue)
lblBudget.Text = decValue.ToString("#.##0")
BTW, you should really put some exception handling in your function or, at
the very least, use the Using syntax... As it stands, any error in the
ExecuteScaler line is liable to leave your connection open...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net