StackOverflow - 我仍在尝试部署此站点,但是解决了每个问题后,出现了另一个问题。无论如何 - 我已经在我的主机上建立了数据库以允许远程连接,并且正在运行Sql Server 2005.在我的开发机器上,我正在使用Sql Server 2008.访问远程存储过程时的语法错误不正确
我已经安装了asp.net架构在我的托管数据库上,并从ASP.NET Web管理界面创建了多个用户,并测试了登录的工作方式。使用远程连接字符串在本地运行应用程序可获得相同的结果。但是 - 我能够运行我的脚本并生成我的表和存储过程而没有错误 - 但是当站点运行时,我在尝试访问存储过程的所有.aspx页面上出现以下错误:
Server Error in '/' Application.
Incorrect syntax near 'LoadProfileData'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'LoadProfileData'.
Source Error:
Line 62: adapter.SelectCommand.Parameters.Add("@ProfessionalName", SqlDbType.VarChar).Value = professionalName;
Line 63: DataSet profile = new DataSet();
Line 64: adapter.Fill(profile, "Profile");
Line 65: return profile;
Line 66: }
这是一个可能的Sql 2005 vs 2008问题?我希望有人在类似的情况下看到了这个问题,并可以指出我正确的方向。该服务器正在运行asp.net 2.0,3.0和3.5以及IIS 7.0。
存储过程:
-- =============================================
-- Create date: <July 2010>
-- Description: <Create default Professional Profile>
-- =============================================
Drop procedure CreateDefaultProfile
GO
Create procedure CreateDefaultProfile(@UserName varchar(256))
as
declare @ProfessionalID uniqueidentifier
set @ProfessionalID = (select UserId from aspnet_Users where UserName = @UserName)
declare @email varchar(256)
set @email = (select Email from aspnet_Membership where UserId = @ProfessionalID)
insert into Professional(ProfessionalID, Name, Email, Phone, TypeID, DisplayPictureUrl, ProfileHeader, ProfileSubHeader, ProfileContent, ServicesHeader, ServicesContent)
values (@ProfessionalID, '', @email, '', '', 'css/img/profilepicture_default.jpg', '', '', '', '', '')
GO
-- exec CreateDefaultProfile 'Mounir'
-- select * from Professional
数据访问层方法:
//"Data Source=localhost;Initial Catalog=MHNProServices;Integrated Security=SSPI"
const string ConnectionString =
"Data Source=mhnproservices.db.5322869.hostedresource.com; Initial Catalog=mhnproservices; User ID=mhnproservices; Password='***********'";
internal static void CreateDefaultProfile(string professionalName)
{
SqlConnection conn = new SqlConnection(ConnectionString);
SqlDataAdapter adapter = new SqlDataAdapter("CreateDefaultProfile @ProfessionalName", conn);
adapter.SelectCommand.Parameters.Add("@ProfessionalName", SqlDbType.VarChar).Value = professionalName;
conn.Open();
adapter.SelectCommand.ExecuteNonQuery();
conn.Close();
}
这将有助于看到实际的源代码 – 2010-07-23 22:55:47