locked
Updating table with selected row RRS feed

  • Question

  •  I have creted a table in sql 2000

    col name data type length

    acctno     int               4

    seqno     int               4

    and fill the data manualy

    acctno    seqno

    100          1

    100          1

    100          1

    100          1

    100          1

    I want to update only seqno column as bellow format

    100          1

    100          2

    100          3

    100          4

    100          5

    I have try to update many time but failed to update because I can not find proper codding to update this table . Please send me codding to update table on selected row condition

    Sunday, June 19, 2011 4:27 AM

Answers

  • Hi,

    I think its not possible to update your table as per your request since it doesn't have any primary key and it violates the primary key constraint.Try creating a primary key and update with reference to it.


    Subramanian Muthukrishnan

    Microsoft Student Partner

    General Secretary,Rockcity Dot Net User Group

    Sunday, June 19, 2011 5:49 AM
  • It's impossible to update your system since you don't have any way to identify a row uniquley. This is what Subramanian has mentioned.

    But I can suggest you a method to achieve what you want ?

    Check my blog post :

    http://thuruinhttp.wordpress.com/2011/06/19/sequence-column-and-identity/

    I created to explain your question,

    But the way you have created your table is a very poor design. In the blog post I have explained how you can create a Sequence Column as well.

     


    My blog : http://thuruinhttp.wordpress.com
    • Proposed as answer by Thuru VMVP Sunday, June 19, 2011 11:41 AM
    • Marked as answer by Cookie Luo Monday, July 11, 2011 8:58 AM
    Sunday, June 19, 2011 11:33 AM
  • Hi

    Without a primary key there is no way to determine which row or rows(tuples) will be updated. Without a primary key there is no way to
    avoid duplicate rows. Without a primary key there is no way to enforce a one to many parent child relationship between tables.

    This is why we need a primary key. Maybe foxpro can, but C# cannot. We should follow the c# world's rule. If you add a primary key, this is really easy for c#.

    Hope this helps.


    Cookie Luo[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Cookie Luo Monday, July 11, 2011 8:58 AM
    Tuesday, June 21, 2011 7:06 AM

All replies

  • Hi,

    I think its not possible to update your table as per your request since it doesn't have any primary key and it violates the primary key constraint.Try creating a primary key and update with reference to it.


    Subramanian Muthukrishnan

    Microsoft Student Partner

    General Secretary,Rockcity Dot Net User Group

    Sunday, June 19, 2011 5:49 AM
  • It's impossible to update your system since you don't have any way to identify a row uniquley. This is what Subramanian has mentioned.

    But I can suggest you a method to achieve what you want ?

    Check my blog post :

    http://thuruinhttp.wordpress.com/2011/06/19/sequence-column-and-identity/

    I created to explain your question,

    But the way you have created your table is a very poor design. In the blog post I have explained how you can create a Sequence Column as well.

     


    My blog : http://thuruinhttp.wordpress.com
    • Proposed as answer by Thuru VMVP Sunday, June 19, 2011 11:41 AM
    • Marked as answer by Cookie Luo Monday, July 11, 2011 8:58 AM
    Sunday, June 19, 2011 11:33 AM
  • I can easily solve this update problem in foxpro how can I believe it is not posible in c sharp however foxpro is old version language and c sharp is a latest language.
    Sunday, June 19, 2011 11:58 PM
  • I can easily solve this update problem in foxpro how can I believe it is not posible in c sharp however foxpro is old version language and c sharp is a latest language.
    Sunday, June 19, 2011 11:59 PM
  • Hi

    Without a primary key there is no way to determine which row or rows(tuples) will be updated. Without a primary key there is no way to
    avoid duplicate rows. Without a primary key there is no way to enforce a one to many parent child relationship between tables.

    This is why we need a primary key. Maybe foxpro can, but C# cannot. We should follow the c# world's rule. If you add a primary key, this is really easy for c#.

    Hope this helps.


    Cookie Luo[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Cookie Luo Monday, July 11, 2011 8:58 AM
    Tuesday, June 21, 2011 7:06 AM
  • Hi, lalyprojectcsharpdya144211 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals

    If you really want to solve this in C# , execute the set of queries (provided in my blog) from C# code

    This is not C# or FoxPro , I think more to do with SQL

     


    My blog : http://thuruinhttp.wordpress.com
    Thursday, June 23, 2011 12:14 PM