using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;namespace GetData { public class GetUserData
{
private string DatabaseConnection = ConfigurationSettings.AppSettings["7thDeSql"];
public DataSet GetDataMan(string ManagerTable) 
{


SqlConnection myConnection = new SqlConnection(DatabaseConnection);
SqlDataAdapter myDataAdapter = new SqlDataAdapter("Select * From "+ ManagerTable +"",myConnection);
DataSet my7thDeDS = new DataSet();
myDataAdapter.Fill(my7thDeDS,ManagerTable); return my7thDeDS;

} }
}

解决方案 »

  1.   

    here is an aspx page adapted from .NET quickstart tutorial:<%@ 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=localhost;database=pubs;uid=sa;pwd=;");
            SqlCommand myCommand = new SqlCommand("select * from Authors", myConnection);        myConnection.Open();        SqlDataReader dr = myCommand.ExecuteReader();        MyDataGrid.DataSource = dr;
            MyDataGrid.DataBind();        myConnection.Close();
        }</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>