0

Anyone can help I am getting an error when I am trying to register for a user, everything is working fine locally but I am getting an error when I upload my files remotely. Heres my code

    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 Name=@Name AND Email=@Email AND Passwords=@Passwords AND Newsletter=@Newsletter AND ReportTemplates=@ReportTemplates AND ReturningMember=@ReturningMember AND Sponsor=@Sponsor)"

    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."

Error I am getting

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 

Stack Trace:

   [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

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
user1983152
  • 67
  • 1
  • 2
  • 14
  • possible duplicate of [Operation must use an updatable query. (Error 3073) Microsoft Access](http://stackoverflow.com/questions/170578/operation-must-use-an-updatable-query-error-3073-microsoft-access) – Joachim Isaksson Feb 25 '13 at 08:37
  • Hey can anyone tell me whats wrong with my code how come it work localy but not remotely, i dont understand the updated query answers can anyone tell me what code I should use with an example please,Im really struggling to get this project done thanks in advance – user1983152 Mar 03 '13 at 17:54

1 Answers1

0

I'm far from being even a novice at Access, but you have an error in your query;

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

should probably be;

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

Your "updatable query" problem though is most likely that you're trying to use SQL server UPDATE query on Access though, Access' UPDATE syntax is far from standard and it's probably required to rewrite your subquery as a join. Someone with more Access-Foo will probably be able to help you with that.

Alternately, you could try the Access Query Wizard which may be able to assist you in rewriting the query with correct Access syntax.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294