Online movie voting system

      Sometimes I encounter a lot of website projects, and the author myself has made websites based on some frameworks. The teacher also taught a lot of skills and methods. After a long time, a lot of skills or common sense have been forgotten, and the C# development website has become very unfamiliar. So the purpose of writing this blog is to remember how to solve some of the installation problems encountered at the beginning. This project is someone else’s, so the source code will not be given here. If it is infringing, I will delete it by contacting or leaving a message. If you download some C# projects on github, you may configure and install them according to my ideas.

     Record an installation of the movie voting system, first introduce your own machine situation, win7 system, VS2012, sqlSever version is 2010. When learning web development in the past, the book standard configuration "ASP.NET", the configured effect is shown in the following figure (some basic functions of the top ticket are realized):

 

First introduce that to the folder directory: film is the specific implementation and solution. The other two are database things.

 

Then the basic idea is to attach the database first, then build the table, then connect to the database, and finally open the solution, click Generate, and then open it in a browser.

Most of the problems encountered when attaching the database first are due to permissions issues. Right click on the database, then click Attach

Then click Attach, click Add, find the database path mentioned earlier, and then click OK:

If the attachment encounters an error, you need to go back to the database file, then open the properties, check the full control, and reattach it to succeed. I have encountered this problem:

Then build the table, the sql statement of the table is as follows;

CREATE TABLE [dbo].[t_film](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[fname] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[pic] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[company] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[director] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[zhuyan] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[shichang] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[juqing] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL,
	[status] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ctime] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_t_film] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[t_gonggao](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[biaoti] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[neirong] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL,
	[ctime] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_t_gonggao] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[t_orders](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[ordersid] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[fname] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[fyt] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[zuoweiid] [int] NULL,
	[paipianid] [int] NULL,
	[pai] [int] NULL,
	[zuo] [int] NULL,
	[info] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[fytime] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[username] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[name] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[price] [int] NULL,
	[phone] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[status] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ctime] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_t_orders] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[t_paipian](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[filmid] [int] NULL,
	[fname] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[theaterid] [int] NULL,
	[mingchen] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[riqi] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[leixing] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[hour] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[price] [int] NULL,
	[status] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[total] [int] NULL,
	[buys] [int] NULL,
	[subpiao] [int] NULL,
 CONSTRAINT [PK_t_paipian] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


CREATE TABLE [dbo].[t_theater](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[mingchen] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[hang] [int] NULL,
	[lie] [int] NULL,
	[zuowei] [int] NULL,
 CONSTRAINT [PK_t_theater] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


CREATE TABLE [dbo].[t_user](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[username] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[password] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[name] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[role] [int] NULL,
	[phone] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[ctime] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_t_user] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


CREATE TABLE [dbo].[t_zuowei](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[paipianid] [int] NULL,
	[pai] [int] NULL,
	[zuo] [int] NULL,
	[status] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[info] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_t_zuowei] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


insert into t_user(username,password,name,role)  values('admin','000000','系统管理员',1)

The resulting table directory is shown in the figure below:

Now start to connect to the database:

Open vs2012, there is a connection database in the tool, click on it

(Note that the server name will be automatically obtained, and you need to wait for about 1 minute), and then enter the corresponding information, and click Test Connection (in my case, the windows identity is successful, the SQL server identity fails, and the password and account are not entered correctly). The following figure shows the successful result of the test connection.

 

Generally speaking, after finding the corresponding C# project on github, the most troublesome thing is to connect VS to SqlSever. The connection interface is similar. I only have two methods. I won’t introduce the other methods. One is a very common method, and the other is. It uses integration (you can see other blog introductions, the most direct and violent one. The first type of my computer often fails, but when I help my classmates, it will succeed again. I guess it is a machine problem). How to get these For information, see this blog

登陆方式
    <add name="DatabaseConnectionString" connectionString="server=xxx;database=xx_db; uid=xx; pwd=xxxxxx"/>


 采用集成
    <add key="MsSql" value="Data Source=xxxx2\MYSQLSERVER;Initial Catalog=ScoreMan;Integrated Security=True"/>

If it still doesn't work, it is recommended to run the project first and modify the content of the project error. My project is just fine.

private static string strCon = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;

%改变上面语句为:
private static string strCon = @"Data Source=xxxxxx\MYSQLSERVER;Initial Catalog=xxx_db;Integrated Security=True";

Save, then click on the solution (SLN) to regenerate, open it in the browser, and run it.

Guess you like

Origin blog.csdn.net/qq_39463175/article/details/106448690