[英]Visual Studio 2010 deployment error
I tried to follow the instructions from the site http://www.mssqltips.com/sqlservertutorial/3008/building-and-deploying-a-database/ to start working with visual studio. 我尝试按照http://www.mssqltips.com/sqlservertutorial/3008/building-and-deploying-a-database/网站上的说明开始使用Visual Studio。 I succeeded testing the connection with the server.
我成功测试了与服务器的连接。 I chose the server name - the name of the computer +"\\sqlexpress" and the Target database name - the name of the database i was building(the same as in the site's instructions).
我选择了服务器名称-计算机名称+“ \\ sqlexpress”和目标数据库名称-我正在建立的数据库名称(与站点说明中的相同)。
Now, when i click Build, in the menu bar, then build DemoDB, the program compiles properly. 现在,当我单击构建时,在菜单栏中,然后构建DemoDB,程序将正确编译。 But when i choose Deploy DemoDB, i get the following error, which i do not understand:
但是当我选择Deploy DemoDB时,出现以下错误,我不理解:
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 ==========
What am i supposed to do? 我应该做些什么? What other setting information should i tell you in order to help me with this?
为了帮助我,我还应该告诉您其他哪些设置信息?
I verified the table DemoDB.sql and i found some errors. 我验证了表DemoDB.sql,发现一些错误。 But those errors are in the code that was generated by visual studio, not in the code i wrote.
但是这些错误是在Visual Studio生成的代码中,而不是在我编写的代码中。 I just followed some steps from a site to create this data base.
我只是从站点按照一些步骤来创建此数据库。 i do not know what else i have to modify.
我不知道我还需要修改什么。 As i said before, i am new with this pragramming languages.
如我之前所说,我是这种语言的新手。
This is the automatic generated code in DemoDB.sql: 这是DemoDB.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)]
--------------------------------------------------------------------------------------
*/
And this is my completion, which is correct, apparently: 这是我的完成,这是正确的,显然是:
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.