Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Visual Studio 2010部署错误_C#_Asp.net_Visual Studio 2010 - Fatal编程技术网

C# Visual Studio 2010部署错误

C# Visual Studio 2010部署错误,c#,asp.net,visual-studio-2010,C#,Asp.net,Visual Studio 2010,我试着按照网站上的指示去做 开始使用visual studio。我成功地测试了与服务器的连接。我选择了服务器名称-计算机名称+“\sqlexpress”和目标数据库名称-我正在构建的数据库名称(与网站说明中的名称相同) 现在,当我在菜单栏中单击Build,然后单击Build demodmb时,程序可以正确编译。但是,当我选择Deploy Demob时,我得到了以下错误,我不理解: Inserting Seed Data for FootBallClub Table C:\Users\john\

我试着按照网站上的指示去做 开始使用visual studio。我成功地测试了与服务器的连接。我选择了服务器名称-计算机名称+“\sqlexpress”和目标数据库名称-我正在构建的数据库名称(与网站说明中的名称相同)

现在,当我在菜单栏中单击Build,然后单击Build demodmb时,程序可以正确编译。但是,当我选择Deploy Demob时,我得到了以下错误,我不理解:

 Inserting Seed Data for FootBallClub Table
C:\Users\john\Documents\Visual Studio 2010\Projects\DemoDB\DemoDB\sql\debug\DemoDB.sql(70,0): Error SQL01268: .Net SqlClient Data Provider: Msg 208, Level 16, State 1, Line 15 Invalid object name 'dbo.FootBallClub'.
    An error occurred while the batch was being executed.
   Done executing task "SqlDeployTask" -- FAILED.
  Done building target "DspDeploy" in project "DemoDB.dbproj" -- FAILED.
 Done executing task "CallTarget" -- FAILED.
Done building target "DBDeploy" in project "DemoDB.dbproj" -- FAILED.
Done building project "DemoDB.dbproj" -- FAILED.

Build FAILED.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

我该怎么办?为了帮助我,我还应该告诉您哪些其他设置信息?

我验证了demodab.sql表,发现了一些错误。但是这些错误出现在VisualStudio生成的代码中,而不是我编写的代码中。我只是按照网站上的一些步骤来创建这个数据库。我不知道还有什么需要修改的。正如我之前所说的,我对这种pragraming语言是新手

这是demodab.sql中自动生成的代码:

/*
Deployment script for DemoDB
*/

GO
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

SET NUMERIC_ROUNDABORT OFF;


GO
:setvar DatabaseName "DemoDB"
:setvar DefaultDataPath "C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\"
:setvar DefaultLogPath "C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\"

GO
USE [master]

GO
:on error exit
GO
IF (DB_ID(N'$(DatabaseName)') IS NOT NULL
    AND DATABASEPROPERTYEX(N'$(DatabaseName)','Status') <> N'ONLINE')
BEGIN
    RAISERROR(N'The state of the target database, %s, is not set to ONLINE. To deploy to this database, its state must be set to ONLINE.', 16, 127,N'$(DatabaseName)') WITH NOWAIT
    RETURN
END

GO

IF NOT EXISTS (SELECT 1 FROM [master].[dbo].[sysdatabases] WHERE [name] = N'$(DatabaseName)')
BEGIN
    RAISERROR(N'You cannot deploy this update script to target JOHN-PC\SQLEXPRESS. The database for which this script was built, DemoDB, does not exist on this server.', 16, 127) WITH NOWAIT
    RETURN
END

GO

IF (@@servername != 'JOHN-PC\SQLEXPRESS')
BEGIN
    RAISERROR(N'The server name in the build script %s does not match the name of the target server %s. Verify whether your database project settings are correct and whether your build script is up to date.', 16, 127,N'JOHN-PC\SQLEXPRESS',@@servername) WITH NOWAIT
    RETURN
END

GO

IF CAST(DATABASEPROPERTY(N'$(DatabaseName)','IsReadOnly') as bit) = 1
BEGIN
    RAISERROR(N'You cannot deploy this update script because the database for which it was built, %s , is set to READ_ONLY.', 16, 127, N'$(DatabaseName)') WITH NOWAIT
    RETURN
END

GO
USE [$(DatabaseName)]

GO
/*
 Pre-Deployment Script Template                         
--------------------------------------------------------------------------------------
 This file contains SQL statements that will be executed before the build script.   
 Use SQLCMD syntax to include a file in the pre-deployment script.          
 Example:      :r .\myfile.sql                              
 Use SQLCMD syntax to reference a variable in the pre-deployment script.        
 Example:      :setvar TableName MyTable                            
               SELECT * FROM [$(TableName)]                 
--------------------------------------------------------------------------------------
*/

GO
/*
Post-Deployment Script Template                         
--------------------------------------------------------------------------------------
 This file contains SQL statements that will be appended to the build script.       
 Use SQLCMD syntax to include a file in the post-deployment script.         
 Example:      :r .\myfile.sql                              
 Use SQLCMD syntax to reference a variable in the post-deployment script.       
 Example:      :setvar TableName MyTable                            
               SELECT * FROM [$(TableName)]                 
--------------------------------------------------------------------------------------
*/

提供demodab.sql中失败的部分。错误消息似乎非常直截了当。运行demodab.sql脚本时,sql报告没有对象“dbo.FootBallClub”。数据库中不存在表FootBallClub
print 'Inserting Seed Data for FootBallClub Table'

insert dbo.FootBallClub select 1, 'Callingmen', 'London'
where not exists (select 1 from dbo.FootBallClub where FootBallClubID=1)

insert dbo.FootBallClub select 2, 'Explorers', 'Barcelona'
where not exists (select 1 from dbo.FootBallClub where FootBallClubID=2)

insert dbo.FootBallClub select 3, 'Autobahns', 'Munich'
where not exists (select 1 from dbo.FootBallClub where FootBallClubID=3)