【发布时间】:2011-04-28 20:38:24
【问题描述】:
显然没有人将visual web dev express连接到数据库,因为我在谷歌上找不到任何有用的东西。
- 我是否需要将数据源连接到我的项目,以便登录控制/等工作?如果没有,还有什么办法?
- 我可以使用哪些(免费!)数据库作为 visual web dev express 中的数据源?
- 如何连接它们?
我的问题有点短,但我必须去,提前谢谢。
【问题讨论】:
标签: asp.net datasource
显然没有人将visual web dev express连接到数据库,因为我在谷歌上找不到任何有用的东西。
我的问题有点短,但我必须去,提前谢谢。
【问题讨论】:
标签: asp.net datasource
答案在这里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
【讨论】:
是的,ASP.NET 的内置成员功能使用数据库来存储他们的信息。
在数据库方面坚持微软?
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
取决于您执行数据访问的方式,但您将从构造连接字符串开始。
【讨论】: