<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.Odbc" %>
<script runat="server">
void Page_Load(object sender, EventArgs e) {
string ConnectionString = @"driver={MySQL ODBC 3.51 Driver};server=localhost;database=books;uid=user;pwd=letmein;";
string CommandText = "select * from employee";
OdbcConnection myConnection = new OdbcConnection(ConnectionString);
OdbcCommand myCommand = new OdbcCommand(CommandText, myConnection);
myConnection.Open();
DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
DataGrid1.DataBind();
myConnection.Close();
}
</script>
<html>
<head>
</head>
<body >
<form runat="server">
<asp:datagrid id="DataGrid1" runat="server" EnableViewState="False">
<HeaderStyle font-bold="True"></HeaderStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
</asp:datagrid>
</form>
</body>
</html>
|