People peopleID peopleName relationship customerID 1 A aunty 1 2 B aunty 1 3 C second uncle 1 4 D aunty 2
Protected Sub GridView2_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView2.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'Do your processing here... Dim txt As TextBox = DirectCast(e.Row.FindControl("Label1"), TextBox) Dim adapter As New SqlDataAdapter Dim ds As New DataSet 'Dim sql As String Dim connectionString = ConfigurationManager.ConnectionStrings("ProjData").ConnectionString Dim myConn As New SqlConnection(connectionString) Dim cmd = "Select * From People Where customerID='" & Session("customerID") & "' " ' Dim myCmd As New SqlCommand(cmd, myConn) Try myConn.Open() Dim myCmd As New SqlCommand(cmd, myConn) adapter.SelectCommand = myCmd adapter.Fill(ds, "People") adapter.Dispose() myCmd.Dispose() txt.Text = ds.Tables(0).Rows.Count Catch ex As Exception MsgBox("Can not open connection ! ") End Try End If End Sub
Protected Sub GridView2_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView2.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'Do your processing here... Dim txt As TextBox = DirectCast(e.Row.FindControl("Label1"), TextBox) Dim adapter As New SqlDataAdapter Dim ds As New DataSet 'Dim sql As String Dim connectionString = ConfigurationManager.ConnectionStrings("ProjData").ConnectionString Dim myConn As New SqlConnection(connectionString) Dim cmd = "SELECT COUNT(distinct(relationship)) FROM People WHERE " & Session("customerID") & " " ' Dim myCmd As New SqlCommand(cmd, myConn) Try myConn.Open() Dim myCmd As New SqlCommand(cmd, myConn) adapter.SelectCommand = myCmd txt.Text = adapter.SelectCommand.ExecuteScalar().ToString() adapter.Dispose() myCmd.Dispose() Catch ex As Exception MsgBox("Can not open connection ! ") End Try End If End Sub
(SELECT COUNT(distinct(relationship)) FROM People WHERE customerID=1)
SELECT customerID, relationship , COUNT(*) AS Expr1 FROM Result WHERE (customerID= 1) GROUP BY customerID, relationship
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)