Apparently no one connects visual web dev express to databases because I can't find anything helpful on go开发者_StackOverflow中文版ogle.
- Do I need to connect a datasource to my project, for the login control/etc to work? If not, how else?
- What (free!) databases can I use as a data source in visual web dev express?
- 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
Yes, the built in Membership features of ASP.NET use a database to store their information.
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
Depends how you perform data access, but you'll start by constructing a connection string.
精彩评论