Results 1 to 4 of 4

Thread: [RESOLVED] Insert, update and delete by datagridview

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Resolved [RESOLVED] Insert, update and delete by datagridview

    Hello everyone,
    I am using vs 2005 and MYSQL .NET CONNECTOR, not I have a dataset.xsd and create a tableadapter in it.
    here is an update query
    Code:
    UPDATE        emp
    SET                  empNo = ?empNo, eName = ?eName, password = ?password, 
                              position = ?position, pwd_expire = ?pwd_expire, lastLogin = ?lastLogin
    when I try to update the first column of value as the following pic, the exception come out!

    Duplicate entry '0000000001' for key 'PRIMARY'




    Can any tell me what is wrong with my query?

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: Insert, update and delete by datagridview

    Aren't you missing a WHERE clause in your query? Here is the documentation on MySQL's UPDATE.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: Insert, update and delete by datagridview

    Thx nmadd, I think it is.

    Should the code be this way?
    Code:
    UPDATE        emp
    SET                  empNo = ?empNo, eName = ?eName, password = ?password, 
                              position = ?position, pwd_expire = ?pwd_expire, lastLogin = ?lastLogin
    WHERE         (emoNo = ?empNo)
    But how do I get the column that I have been corrected it?

    I have an emp table:
    Me.SlmcDataSet1.emp.empNoColumn

  4. #4
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: Insert, update and delete by datagridview

    Sorry, I'm not sure I understand your question nor do I have experience in MySQL. But the documentation linked to above says this about what UPDATE returns:

    Code:
    UPDATE returns the number of rows that were actually changed. 
    The mysql_info() C API function returns the number of rows that were matched 
    and updated and the number of warnings that occurred during the UPDATE.
    Good luck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width