Operation must use an updateable query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • waqasmgl
    New Member
    • Nov 2007
    • 20

    Operation must use an updateable query

    Below is the code i am using to insert a record in msaccess database.
    I am getting an error that bcmd must use an Updateable query.
    Error screenshot is attached....

    Code:
            Dim strsql as string, rGender as string
    		dim BCon As OleDbConnection
    		dim bcmd as OleDbCommand
    				
    			if rbMale.checked = false then 
    				rGender = "Female"
    			else
    				rGender = "Male"
    			end if
    			Bcon = New OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("/AN/db/data.mdb"))
    	 		'strsql = "INSERT INTO oApply VALUES ('" & txtUsername.text & "', '" & txtPassword.text & "', '" & txtName.text & "', '" & rGender & "', '" & txtNIC.text & "', '" & txtPassport.text & "', '" & txtPhone.text & "', '" & txtMobile.text & "', '" & txtAddress.text & "', '000')"
    			
    			strsql = "INSERT INTO oApply VALUES (@Username, @Password, @Name, @Gender, @NIC, @Passport, @Phone, @Mobile, @Address, @Date)"
    			
    			Bcon.open
    	        
    			bcmd = New OleDbCommand(strsql, bcon)
    			
    			With bcmd.Parameters:
    				.Add(New OleDbParameter("@Username", txtUsername.text))
    				.Add(New OleDbParameter("@UPassword", txtPassword.text))
    				.Add(New OleDbParameter("@Name", txtName.text))
    				.Add(New OleDbParameter("@Gender", rGender))
    				.Add(New OleDbParameter("@NIC", txtNIC.text))
    				.Add(New OleDbParameter("@Passport", txtPassport.text))
    				.Add(New OleDbParameter("@Phone", txtPhone.text))
    				.Add(New OleDbParameter("@Mobile", txtMobile.text))
    				.Add(New OleDbParameter("@Address", txtAddress.text))
    				.Add(New OleDbParameter("@Date", "000"))
    			end with
    			
    	    	bcmd.ExecuteNonQuery()			
    		
            	bcon.close

    For better view of error message: http://www.mediafire.com/file/1zkt41ownli/Capture.JPG
    Attached Files
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Until someone with more experience can offer more targeted advice I can point you toward these:

    Database tutorial Part 1
    Database tutorial Part 2

    Comment

    • waqasmgl
      New Member
      • Nov 2007
      • 20

      #3
      Originally posted by tlhintoq
      Until someone with more experience can offer more targeted advice I can point you toward these:

      Database tutorial Part 1
      Database tutorial Part 2
      Sir my syntax is OK.... Code is all ok... but i m confused why i m getting this error?
      I m using an updateable query then why the server is giving this error?

      Comment

      • semomaniz
        Recognized Expert New Member
        • Oct 2007
        • 210

        #4
        This might be helpful http://support.microsoft.com/kb/175168


        Also

        For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          Isn't it just amazing what you can find when you search?
          I practically live on Google.

          "MSDN MySearchTermPro blemHere" is always my first effort, followed by
          "C# MySearchTermPro blemHere"

          Comment

          • semomaniz
            Recognized Expert New Member
            • Oct 2007
            • 210

            #6
            True google is the first place to check.

            Comment

            • waqasmgl
              New Member
              • Nov 2007
              • 20

              #7
              I got my problem.... i tried many times but didnt try the error search. This problem occurs when we dont have permission to write on database folder.
              I asked my server support and they gave the rights to me now its all ok...
              But i m amazed that none of u knw this.

              Comment

              • tlhintoq
                Recognized Expert Specialist
                • Mar 2008
                • 3532

                #8
                waqasmgl: But i m amazed that none of u knw this.
                No need to be nasty. It's your network. I'm amazed that you wouldn't know your own network permissions. Or how to type 'you' or 'know'.

                The folks here have a fine line to walk. Do you go down to such a basic level as to ask the coder if their PC is plugged in... is your cat5 connected... do you have permissions to your own project folder... Many people would find such questions insulting.

                Windows error messages are also not the always the most helpful. Often times the same message is thrown for 10 different reasons. I never thought it particularly intuitive that you get an error message of "Out of memory" if you try to open a .jpg that is still being written by another program or still being copied to the destination folder.

                Comment

                • Frinavale
                  Recognized Expert Expert
                  • Oct 2006
                  • 9749

                  #9
                  Waqasmgl, thank you for sharing your solution with us.

                  I'm sure that other people who are facing the same problem will find this information helpful and it could save them a headache too.

                  -Frinny

                  Comment

                  • waqasmgl
                    New Member
                    • Nov 2007
                    • 20

                    #10
                    I m so sorry for my rude behavior, that was because of tension i was facing at that time... i need to show the site to my customer the very next day and i was tensed.
                    Thank you very much for being understanding.

                    Comment

                    Working...