About VS2012 How to connect to SQL database (text step)

Source: Internet
Author: User

First create an ASP empty Web application

Right-click on the project to create a Aspnet folder after you've built it.

App_Data is used to store Mook Jong database files.

A database can be created in the newly created file.

There are two types of databases

One for the local database *.sdf is the server CE driver, this is the local database, but not complete.

One for SQL database *.mdf is the SQL Server database, which must be regenerated when uploading to the server.

Now I use MDF to create a name that is simply written as D.mdf, and then a database connection appears in Server Explorer, note that this is not a connection string.

Create a data table in the database, such as Table_user

Note how to add an AutoNumber to an ID:

The attribute in the right looks for the labeling specification

In the indicator specification Increment 1 increase seed start number like 0001

CREATE TABLE [dbo]. [Table_user]//table name
(
[UID] INT not NULL PRIMARY KEY IDENTITY,
[UserName] NCHAR (Ten) is not NULL,
[Userpass] NCHAR (Ten) is not NULL,
[UserEmail] NCHAR (Ten) is not NULL,
[Userregtime] DATETIME not NULL,
[Usernick] NCHAR (Ten) NULL
)

Then click on the above update, update the database, the data table is set up, and now on the database point right click on the refresh.

Provides a build link string for the database.

I often create a Web form, create a SqlDataSource1, and then click Configure Data source on the design mode,

Then choose the established database, according to the wizard to establish a string connection connectionstring, in fact, the default is good. Easy to call

About VS2012 How to connect to SQL database (text step)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.