<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %><html>
<script language="C#" runat="server"> protected void Page_Load(Object sender, EventArgs e)
{
SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;database=pubs;Integrated Security=SSPI");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors", myConnection); DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors"); MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
}</script><body> <h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3> <ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/></body>
</html>
<%@ Import Namespace="System.Data.SqlClient" %><html>
<script language="C#" runat="server"> protected void Page_Load(Object sender, EventArgs e)
{
SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;database=pubs;Integrated Security=SSPI");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors", myConnection); DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors"); MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
MyDataGrid.DataBind();
}</script><body> <h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3> <ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/></body>
</html>
<%@ Import Namespace="System.Data.SqlClient" %><html><script language="C#" runat="server"> protected void Page_Load(Object sender, EventArgs e)
{
string myConnectionString = "User ID = cmpum;password= guojh;Initial Catalog = cmpuManagesys; Data Source=app5srv";
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlDataAdapter myCommand = new SqlDataAdapter("select * from softappltable where softno ='F-J001'", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "softappltable"); MyDataGrid.DataSource=ds.Tables["softappltable"].DefaultView;
MyDataGrid.DataBind();
}</script>
<body> <h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3> <ASP:DataGrid id="Datagrid1" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/></body>
</html>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3> <ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/> </form>
</body>
</html>你好! 真心感谢你的帮助。还有一点点小问题,我是想把从数据库中选择出来的一条记录写到我画好的一个表单中。再请你帮助。