2013-02-25 57 views
0

當我嘗試註冊用戶時,任何人都可以幫助我收到錯誤,但本地一切正常,但在遠程上傳文件時出現錯誤。我的繼承人代碼將我的文件上傳到Internet時出現錯誤?

Dim conn As OleDbConnection 
    Dim strinsert As String 
    Dim cmdinsert As OleDbCommand 

    conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|sabersolutions.mdb") 
    strinsert = "INSERT INTO register(Name,Email,Passwords,Newsletter,ReportTemplates,ReturningMember,Sponsor)SELECT TOP 1 @Name,@Email,@Passwords,@Newsletter,@ReportTemplates,@ReturningMember,@Sponsor FROM register WHERE NOT EXISTS(SELECT 1 FROM register WHERE [email protected] AND [email protected] AND [email protected] AND [email protected] AND [email protected] AND [email protected] AND [email protected])" 

    cmdinsert = New OleDbCommand(strinsert, conn) 
    cmdinsert.Parameters.Add("@Name", OleDbType.VarWChar, 255).Value = txtName.Text 
    cmdinsert.Parameters.Add("@Email", OleDbType.VarWChar, 255).Value = txtEmail.Text 
    cmdinsert.Parameters.Add("@Passwords", OleDbType.VarWChar, 255).Value = txtPass.Text 
    cmdinsert.Parameters.Add("@Sponsor", OleDbType.Boolean, 1).Value = ckSponsor.Checked 
    cmdinsert.Parameters.Add("@Newsletter", OleDbType.Boolean, 1).Value = ckNews.Checked 
    cmdinsert.Parameters.Add("@ReportTemplates", OleDbType.Boolean, 1).Value = ckReportTemp.Checked 
    cmdinsert.Parameters.Add("@ReturningMember", OleDbType.Boolean, 1).Value = ckRSponsor.Checked 
    cmdinsert.Parameters.Add("@Sponsor", OleDbType.Boolean, 1).Value = ckSponsor.Checked 

    cmdinsert.Connection.Open() 

    cmdinsert.ExecuteNonQuery() 

    cmdinsert.Connection.Close() 

    LblSuccess.Text = "You have successfully Register, Please Login to view our Online Booking Sytem." 

錯誤我得到

Server Error in '/' Application. 

Operation must use an updateable query. 

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.OleDb.OleDbException: Operation must use an updateable query. 

Source Error: 


Line 27:   cmdinsert.Connection.Open() 
Line 28: 
Line 29:   cmdinsert.ExecuteNonQuery() 
Line 30: 
Line 31:   cmdinsert.Connection.Close() 

Source File: C:\inetpub\vhosts\sabersolutions.co.za\httpdocs\RegisterandLoginForm.aspx.vb Line: 29 

堆棧跟蹤:

[OleDbException (0x80004005): Operation must use an updateable query.] 
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1081356 
    System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247 
    System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194 
    System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58 
    System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +167 
    System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +113 
    RegisterandLoginForm.Button2_Click(Object sender, EventArgs e) in C:\inetpub\vhosts\sabersolutions.co.za\httpdocs\RegisterandLoginForm.aspx.vb:29 
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112 
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563 

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.272

+0

[操作必須使用可更新查詢。 (錯誤3073)微軟Access](http://stackoverflow.com/questions/170578/operation-must-use-an-updatable-query-error-3073-microsoft-access) – 2013-02-25 08:37:16

+0

嘿,任何人都可以告訴我什麼是錯的,我的代碼如何工作本地化,但不是遠程,我不明白更新的查詢答案任何人都可以告訴我什麼代碼,我應該用一個例子,我真的很努力得到這個項目在此先感謝 – user1983152 2013-03-03 17:54:22

回答

0

我遠不是Access的新手,但是你的查詢有錯誤;

.... 
SELECT TOP 1 @Name,@Email,@Passwords,@Newsletter, 
      @ReportTemplates,@ReturningMember,@Sponsor 
FROM register 
... 

應該是;

.... 
SELECT TOP 1 Name,Email,Passwords,Newsletter, 
      ReportTemplates,ReturningMember,Sponsor 
FROM register 
... 

你的「更新查詢」問題,但最有可能是你想獲取使用SQL Server UPDATE查詢雖然,訪問UPDATE語法是遠離標準和它可能需要重寫子查詢作爲加入。有更多Access-Foo的人可能會幫助你。

或者,您可以嘗試訪問查詢嚮導,它可以幫助您用正確的Access語法重寫查詢。

+0

它仍然給出了同樣的錯誤,不知道該做什麼了! – user1983152 2013-03-04 09:27:09

+0

@ user1983152您是否嘗試過上述訪問查詢嚮導? – 2013-03-04 11:29:03

相關問題