سلام دوستان
میخواستم بدانم در ASP.Net 2 VB چگونه میتوان تعداد رکورد را از یک جدول بدست آورد و به یک لیبل داد؟
درواقع میخواهم تعداد کاربران را بدست بیارم.
مرسی
select count(*) from TableName
مرسی از راهنمائی
میخواستم بدونم که نباید کانکشن استرینگ را بگم کدومشو استفاده کنه؟
یک سوال دیگر اینکه این موقع لود شدن صفحه باید استفاده کرد؟
چطوری حاصل را به یک متغییر بدم ؟
نه دوست عزیز من تعداد کاربران ثبت نام شده را میخواهم بدست بیارم لطفا اگر میدونید چطوری باید حاصل را تو یک متغییر بریزم را بگید
مرسی
UserCount = Convert.ToInt32(cmd.ExecuteScalar())
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
LabelNoOnlineUser.Text = Application.Get("OnlineUser").ToString()
Dim UserDataSourse As New SqlDataSource()
UserDataSourse.ConnectionString = ConfigurationManager.ConnectionStrings("SiteSQLServer").ToString()
UserDataSourse.SelectCommandType = SqlDataSourceCommandType.Text
UserDataSourse.SelectCommand = "select count(*) from aspnet_Users"
Dim UserCount As String
UserCount = Convert.ToInt32(cmd.ExecuteScalar())
LabelUserCount.Text = UserCount
End Sub
End Class
Dim UserCount As String
UserCount = Convert.ToInt32(cmd.ExecuteScalar())
Dim UserDataSourse As New SqlDataSource()
UserDataSourse.ConnectionString = ConfigurationManager.ConnectionStrings("SiteSQLServer").ToString()
UserDataSourse.SelectCommandType = SqlDataSourceCommandType.Text
UserDataSourse.SelectCommand = "select count(*) from aspnet_Users"
Dim UserCount As Integer = Convert.ToInt32(cmd.ExecuteScalar())
LabelUserCount.Text = UserCount
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'cmd' is not declared.
Source Error:
Line 11: UserDataSourse.SelectCommand = "select count(*) from aspnet_Users"
Line 12:
Line 13: Dim UserCount As Integer = Convert.ToInt32(cmd.ExecuteScalar())
Line 14:
Line 15: LabelUserCount.Text = UserCount
'Get the User Count from Database
Dim Userconn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("SiteSQLServer").ToString())
Dim Usercmd As New System.Data.SqlClient.SqlCommand("select count(*) from aspnet_Users", Userconn)
Userconn.Open()
Dim UserCount As Integer = Convert.ToInt32(Usercmd.ExecuteScalar())
Userconn.Close()
LabelUserCount.Text = UserCount