数据库为csg,表名为one,属性为a,b用的是SQL不知道为什么打开后浏览器什么都没有??????我的表里有数据的啊!
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="b2.aspx.cs" Inherits="_Default" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %><script runat="server">
void Page_Load()
{
string strSQL = "SELECT a,b FROM one;";
string strConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=csg;Data Source=SLXX666;";
DataSet objdataset = new DataSet();
SqlConnection objConnection = new SqlConnection(strConnection);
SqlDataAdapter objdataAdapter = new SqlDataAdapter(strSQL, objConnection);
objdataAdapter.Fill(objdataset, "one");
DataView objdataview = new DataView(objdataset.Tables["one"]);
employees1.DataSource = objdataview;
employees1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form runat="server" id="ss"> <asp:DataGrid ID="employees1" runat="server" OnSelectedIndexChanged="employees1_SelectedIndexChanged" >
</asp:DataGrid>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="b2.aspx.cs" Inherits="_Default" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %><script runat="server">
void Page_Load()
{
string strSQL = "SELECT a,b FROM one;";
string strConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=csg;Data Source=SLXX666;";
DataSet objdataset = new DataSet();
SqlConnection objConnection = new SqlConnection(strConnection);
SqlDataAdapter objdataAdapter = new SqlDataAdapter(strSQL, objConnection);
objdataAdapter.Fill(objdataset, "one");
DataView objdataview = new DataView(objdataset.Tables["one"]);
employees1.DataSource = objdataview;
employees1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form runat="server" id="ss"> <asp:DataGrid ID="employees1" runat="server" OnSelectedIndexChanged="employees1_SelectedIndexChanged" >
</asp:DataGrid>
</form>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货