【问题标题】:ASP.NET Database optionsASP.NET 数据库选项
【发布时间】:2011-04-28 20:38:24
【问题描述】:

显然没有人将visual web dev express连接到数据库,因为我在谷歌上找不到任何有用的东西。

  1. 我是否需要将数据源连接到我的项目,以便登录控制/等工作?如果没有,还有什么办法?
  2. 我可以使用哪些(免费!)数据库作为 visual web dev express 中的数据源?
  3. 如何连接它们?

我的问题有点短,但我必须去,提前谢谢。

【问题讨论】:

    标签: asp.net datasource


    【解决方案1】:

    答案在这里Using the Web.Config to set up my SQL database connection string?

    这就是你所需要的!

    更新

    一个小例子: 首先将引用 System.Configuration 添加到您的项目中,然后在您的代码中导入(使用 System.Configuration)。

    DataSet ds = new DataSet(); //Create a DataSet
    string ConnectionString = ConfigurationManager.ConnectionStrings["YourConnectionStringName"].ConnectionString; //ConnectionString from web.config
    SqlConnection con = new SqlConnection(); //Create a new SqlConnection
    con.ConnectionString = ConectionString; //Connect using your ConnectionString
    SqlDataAdapter da = new SqlDataAdapter("Your SQL query goes here", con); //Get Data
    da.Fill(ds); //Fill a DataSet (in this case)
    con.Close(); //Close connection
    

    【讨论】:

    • 好的,我有一个连接字符串,但是我该怎么做呢?我已经在 web.config 下添加了它,但是我如何告诉 VWD 使用并连接到它?
    【解决方案2】:
    1. 是的,ASP.NET 的内置成员功能使用数据库来存储他们的信息。

    2. 在数据库方面坚持微软?

      SQL Server Express: http://www.microsoft.com/express/Database/

      SQL Server Compact 4.0: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=033cfb76-5382-44fb-bc7e-b3c8174832e2

    3. 取决于您执行数据访问的方式,但您将从构造连接字符串开始。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-21
      • 2012-01-28
      • 2013-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多