Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to count the record in the database?
    text
    copied!<p>i have this database table called people</p> <pre><code> People peopleID peopleName relationship customerID 1 A aunty 1 2 B aunty 1 3 C second uncle 1 4 D aunty 2 </code></pre> <p>how am i going to count the number of people where the customerID = 1 and if the relationship is the same, it is counted as 1 </p> <p>so from the database table above, i should get the result of 3 and put the result of 3 in Label1 in gridview?</p> <p>i can get the count value for the only where the customerID =1 but i can't figure out how am i going to count if the relationship part</p> <pre><code> 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='" &amp; Session("customerID") &amp; "' " ' 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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload