CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
IBM Rational 系统开发最佳实践工具包 WebSphere MQ 最佳实践 TOP 15
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

谁能给我一个vs2005连接sql server 2005数据库的例子

楼主AgainWarning()2006-03-18 11:27:54 在 .NET技术 / ASP.NET 提问

谁能给我一个在windows   server   2003下visual   studio   2005连接sql   server   2005数据库的例子。先谢谢! 问题点数:10、回复次数:2Top

1 楼iuhxq(小灰)回复于 2006-03-18 11:32:01 得分 5

<%@   Page   Language="C#"   %>  
  <html>  
  <head   runat="server">  
      <title>GridView   Bound   to   SqlDataSource</title>  
  </head>  
  <body>  
      <form   id="form1"   runat="server">  
          <asp:GridView   ID="GridView1"   DataSourceID="SqlDataSource1"   runat="server"   />  
          <asp:SqlDataSource   ID="SqlDataSource1"   runat="server"    
              SelectCommand="SELECT   [au_id],   [au_lname],   [au_fname],   [phone],   [address],   [city],   [state],   [zip],   [contract]   FROM   [authors]"  
              ConnectionString="<%$   ConnectionStrings:Pubs   %>"   />  
      </form>  
  </body>  
  </html>  
   
   
  web.config  
  <?xml   version="1.0"?>  
  <configuration>  
    <connectionStrings>  
          <!--  
          This   connection   is   inherited   from   the   ASP.NET   Quickstart   Web.config   file  
          Uncomment   this   section   to   edit   the   sample   locally  
   
          <add   name="Pubs"   connectionString="Server=(local)\SQLExpress;Integrated   Security=True;Database=pubs;Persist   Security   Info=True"  
              providerName="System.Data.SqlClient"   />  
          <add   name="Northwind"   connectionString="Server=(local)\SQLExpress;Integrated   Security=True;Database=Northwind;Persist   Security   Info=True"  
              providerName="System.Data.SqlClient"   />  
          <add   name="Contacts"   connectionString="Server=(local)\SQLExpress;Integrated   Security=True;Database=Contacts;Persist   Security   Info=True"  
            providerName="System.Data.SqlClient"   />  
          -->  
          <add   name="NorthwindOLEDB"   connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data   Source=|DataDirectory|Northwind.mdb;"  
            providerName="System.Data.OleDb"   />  
          <add   name="ContactsDatabase"   connectionString="Data   Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated   Security=True;User   Instance=true;"  
            providerName="System.Data.SqlClient"   />  
    </connectionStrings>  
          <system.web>  
                  <pages   styleSheetTheme="Default"/>  
                  <caching>  
                          <sqlCacheDependency   enabled="true"   pollTime="1000">  
                                  <databases>  
                                          <add   name="Pubs"   connectionStringName="Pubs"/>  
                                  </databases>  
                          </sqlCacheDependency>  
                  </caching>  
                  </system.web>  
  </configuration>  
  Top

2 楼hblzg(心开风神)回复于 2006-03-18 11:38:48 得分 5

插入SqlDataSource控件,一步步提示的很简单。  
  如果自己写和2003的一样,webconfig中写连接字符串。。。Top

相关问题

  • 关于sql server数据库?
  • SQL Server数据库减肥
  • 连接数据库sql server
  • 发布SQL Server数据库
  • java连SQL Server数据库
  • SQL SERVER建数据库
  • SQL SERVER建数据库
  • 连接数据库SQL SERVER?
  • sql-server数据库问题~~!~
  • 连接SQL Server数据库

关键词

得分解答快速导航

  • 帖主:AgainWarning
  • iuhxq
  • hblzg

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo