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与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();
}