PDA

View Full Version : سوال: اشکال در کد حاصل جمع فیلد



VS2010
پنج شنبه 12 شهریور 1388, 12:21 عصر
آیا این کد برای جمع یک فیلد تو جدول درسته یا نه من که از این استفاده میکنم پیغام میده


Function bazdidkol() As Integer
Dim coon As New SqlConnection(System.Web.Configuration.WebConfigur ationManager.ConnectionStrings("constr").ToString)
Dim obj As New SqlCommand("Select sun(Numbers) from Asp_bazdid", coon)
coon.Open()
Dim maid As Integer = obj.ExecuteScalar
Return maid
coon.Close()
End Function


پیغام


Server Error in '/forum' Application.
--------------------------------------------------------------------------------

'sun' is not a recognized built-in function name.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: 'sun' is not a recognized built-in function name.

Source Error:


Line 78: Dim obj As New SqlCommand("Select sun(Numbers) from Asp_bazdid", coon)
Line 79: coon.Open()
Line 80: Dim maid As Integer = obj.ExecuteScalar
Line 81: Return maid
Line 82: coon.Close()


Source File: D:\Document\Visual Studio 2005\WebSites\forum\App_Code\masterPageClass.vb Line: 80

behnam-s
پنج شنبه 12 شهریور 1388, 15:11 عصر
توی خط سوم
Dim obj As New SqlCommand("Select sun(Numbers) from Asp_bazdid", coon)
sun یعنی چی؟ بنویس sum
Dim obj As New SqlCommand("Select sum(Numbers) from Asp_bazdid", coon)