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