Dim sSql As String = "select count(*) from machin"
Dim oConn As New SqlConnection(ConfigurationSettings.GetConfig("appSettings")("ConnString"))
Dim oComm As New SqlCommand(sSql)
oComm.Connection = oConn
oConn.Open()
''On récupére les informations du count
Dim iResultat As Integer = oComm.ExecuteScalar()
Dim dr As SqlDataReader = oComm.ExecuteReader()
Dim monString As String
TextBox1.Text = iResultat '' test compter nb d'enregistrement
TextBox2.Text = dr.FieldCount '' test compter nb colonne
'' création du tableau
MonTableau.Width = "100%"
MonTableau.CellPadding = "1"
MonTableau.CellSpacing = "0"
MonTableau.Border = "2"
Dim colonne As Integer, ligne As Integer
For ligne = 0 To iResultat
Dim Maligne As New HtmlTableRow
For colonne = 0 To dr.FieldCount
Dim MaCase As New HtmlTableCell
MaCase.Width = "10%"
MaCase.InnerHtml = dr((colonne)).ToString
Maligne.Cells.Add(MaCase)
Next
MonTableau.Rows.Add(Maligne)
Next
Partager