1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
<%
// Chaîne de connexion
SqlConnection conn =
new SqlConnection("Server=xpto;DataBase=extra;Integrated Security=SSPI;");
// Ouverture de la connexion
conn.Open();
// l'objet command, "selectSuggestIntra" est le nom de ma store procedure qui est = á "SELECT Nom, Prenom FROM table"
SqlCommand cmd =
new SqlCommand("selectSuggestIntra", conn);
// Type de command
cmd.CommandType = CommandType.StoredProcedure;
// l'Objet DATA READER
SqlDataReader myReader;
// Execution de la requête
myReader = cmd.ExecuteReader();
while (myReader.Read())
{ %>
<table>
<tr>
<td>
<asp:Label ID="lblNom" Text="<%myReader.GetString(0).ToString(); %>" runat="server"></asp:Label>
</td>
<td>
<asp:Label ID="lblPrenom" Text="<%myReader.GetString(1).ToString(); %>" runat="server"></asp:Label>
</td>
</tr>
</table>
<%}
myReader.Close();
Conn.Close();%> |
Partager