初学者asp.net/c#连接并查询sql server2005的小例子所出现的问题
<%@ Import Namespace="System.Data" %>
<%@ Import NameSpace="System.Data.SqlClient" %>
<script language="c#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection myConnection = New SqlConnection("server=PC-201101031142\SQLEXPRESS;uid=sa;pwd=aaa;database=test");
myConnection.Open()
la1.text="Connection Opened!"
SqlCommand myCommand = New SqlCommand( "select * from [testtable]", myConnection )
MyDataGrid.DataSource=myCommand.ExecuteReader()
MyDataGrid.DataBind()
}
</script>
<html>
<body>
<asp:label id="la1" runat="server" /><br>
<ASP:DataGrid id="MyDataGrid" runat="server"
BorderColor="black"
BorderWidth="1"
GridLines="Both"
CellPadding="3"
CellSpacing="0"
Font-Name="Verdana"
Font-Size="10pt"
HeaderStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="#eeeeee"
>
</asp:DataGrid>
</body>
</html>