在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
webconfig配置: 复制代码 代码如下: <connectionStrings> <add name="MSSQL" connectionString="Data Source=localhost;Initial Catalog=test;User ID=sa;password=sa;" providerName="System.Data.SqlClient"/> </connectionStrings> 前台aspx: 复制代码 代码如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DB.aspx.cs" Inherits="DB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DB</title> </head> <body> <form id="form1" runat="server"> <div> MS SQL<asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> </form> </body> </html> 后台代码: 复制代码 代码如下: using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.Common;//記得要using using System.Configuration; public partial class DB : System.Web.UI.Page protected DataSet GetDataSet(string SqlCommand,string DB) DataSet ds = new DataSet(); DbCommand dbCommand = dbProviderFactory.CreateCommand(); return ds; |
请发表评论