开发者

ASP.NET Database options

Apparently no one connects visual web dev express to databases because I can't find anything helpful on go开发者_StackOverflow中文版ogle.

  1. Do I need to connect a datasource to my project, for the login control/etc to work? If not, how else?
  2. What (free!) databases can I use as a data source in visual web dev express?
  3. How do I connect them?

My question is a little short but I have to go, thanks in advance.


The answer is here Using the Web.Config to set up my SQL database connection string?

Thats all you need!

UPDATE

A little example: First add the reference System.Configuration to your project then Imports in your code (using 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


  1. Yes, the built in Membership features of ASP.NET use a database to store their information.

  2. Sticking with Microsoft for the DB?

    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. Depends how you perform data access, but you'll start by constructing a connection string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜