skip to main |
skip to sidebar
RSS Feeds
Nope. nothing .. just some random thoughts come to my mind ...
Nope. nothing .. just some random thoughts come to my mind ...
11:34 AM | Tuesday, May 15, 2012
Posted by harshadura
Reference : http://www.stardeveloper.com/articles/display.html?article=2002041001&page=3
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(Object sender, EventArgs e) {
SqlConnection con = null;
SqlCommand cmd = null;
try {
con = new SqlConnection("server=localhost;uid=sa;" +
"pwd=;database=Stardeveloper");
cmd = new SqlCommand("SELECT * FROM Names", con);
con.Open();
grid.DataSource = cmd.ExecuteReader();
grid.DataBind();
} catch (Exception err) {
message.Text = "<p><font color=\"red\">Err: " +
err.Message + "</font></p>";
} finally {
if(con != null)
con.Close();
}
}
</script>
<html>
<head>
<style>
body { font-family:Verdana; font-size:12pt; }
</style>
</head>
<body>
<asp:datagrid id="grid" runat="server" />
<asp:label id="message" runat="server" />
</body>
</html>
Post a Comment