delete command

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike & Dyan

    #1

    delete command

    I was able to figure out how to insert new data into my database. But for
    some reason and a lot of reading I can't seem to figure out how to delete
    any data.

    My app is going to be used for tracking info on vehicles. My app is MDI
    with 3 children. 1 is for selecting a car(already in the database) and input
    info.Then you can add that car and info to the database. Another is used for
    just adding or deleting a car to the database. The 3rd is where the data is
    viewed via a datagrid. I have 2 tables. 1 is car names, carID,
    model,Etc..the other is for maintenance logs ie miles and etc....

    Either I just don't get it or the method for deleting data is not explained
    very well. I have been only using .NET for a few months and have very
    little programming experience.

    I need to be able to delete the car name from the NameTable and then delete
    all info on that car from the carinfotable.

    If anyone can point me in the right direction I would be greatful
    Thx in advance.


  • Jeff Louie

    #2
    Re: delete command

    In a database relationship declared ON DELETE RESTRICT you would need to
    delete all rows in the child table carinfotable before you can delete
    the parent
    row. If you want you can change ON DELETE RESTRICT to ON DELETE
    CASCADE which automatically deletes andy carinfotable rows related to
    the
    car name row.

    Regards,
    Jeff
    I need to be able to delete the car name from the NameTable and then
    delete
    all info on that car from the carinfotable.


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

    Comment

    • Cor Ligthert

      #3
      Re: delete command

      Mike & Dyan

      In dotNet there can be a lot of methods be used to get the data, according
      to that there are a lot of methods to delete the data. Can you tell
      something more about that.

      Do you use in General
      AdoNet
      AdoDB
      Any other method

      Than when Adonet by instance
      By a datareader or by a dataset

      And more of this kind of information.

      Not you got from Jeff an answer using direct SQL however one of the
      thousands to choose form probably..

      Cor


      Comment

      • Nick Malik [Microsoft]

        #4
        Re: delete command

        In addition to the information Cor asked for, can you also tell us:

        Are you storing your data in SQL Server (full version or MSDE), Access, or
        some other database?
        Are you familiar with SQL queries? (INSERT, SELECT, DELETE)
        Are you familiar with stored procedures?
        What information forms the primary key for your NameTable?
        What information forms the foreign key for the carinfotable?

        While Jeff responded with a very technical answer, I'd like to repeat one of
        the key points he made:
        If you are using referential integrity in your database, you will have to
        delete rows from the carinfotable first and then from the NameTable. I
        would add: If you are not using referential integrity in your database, you
        should be. ;-)

        --
        --- Nick Malik [Microsoft]
        MCSD, CFPS, Certified Scrummaster
        http://blogs.msdn.com/nickmalik

        Disclaimer: Opinions expressed in this forum are my own, and not
        representative of my employer.
        I do not answer questions on behalf of my employer. I'm just a
        programmer helping programmers.
        --
        "Mike & Dyan" <mikedyan@comca st.net> wrote in message
        news:M5ednURHiJ _oLb7fRVn-sw@comcast.com. ..[color=blue]
        >I was able to figure out how to insert new data into my database. But for
        >some reason and a lot of reading I can't seem to figure out how to delete
        >any data.
        >
        > My app is going to be used for tracking info on vehicles. My app is MDI
        > with 3 children. 1 is for selecting a car(already in the database) and
        > input info.Then you can add that car and info to the database. Another is
        > used for just adding or deleting a car to the database. The 3rd is where
        > the data is viewed via a datagrid. I have 2 tables. 1 is car names, carID,
        > model,Etc..the other is for maintenance logs ie miles and etc....
        >
        > Either I just don't get it or the method for deleting data is not
        > explained very well. I have been only using .NET for a few months and
        > have very little programming experience.
        >
        > I need to be able to delete the car name from the NameTable and then
        > delete all info on that car from the carinfotable.
        >
        > If anyone can point me in the right direction I would be greatful
        > Thx in advance.
        >[/color]


        Comment

        • Mike McIntire

          #5
          Re: delete command



          Like I said I have very little programming experience. I am doing this
          for a friend and because I would like to learn how to program. I do not
          know if I have set the database relationship declared to anything or
          not. How and where would I look to verify this.

          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          • Jeff Louie

            #6
            Re: delete command

            Mike... Database administration alone is a full time job. Writing
            database GUIs
            alone is a full time job. It is somewhat rare to find someone good at
            both. In
            your project go to the service explorer, select the database, create a
            new
            database diagram, add all the tables, right click on the relationship
            arrow and
            select properties, select relationships. If you are new to databases
            check out:

            Database Design For Mere Mortals Hernandez

            If you want to go crazy read:

            An Introduction to Database Design Date
            Handbook of Relational Database Design von Halle

            If you are using MSDE, SQL

            Inside SQL Server Soukup
            Transact-SQL Programming Kline

            Regards,
            Jeff
            Like I said I have very little programming experience. I am doing this
            for a friend and because I would like to learn how to program. I do not
            know if I have set the database relationship declared to anything or
            not. How and where would I look to verify this.


            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            • Mike McIntire

              #7
              Re: delete command

              Before I go any further I would like to thank you for your help. I
              followed the instructions to make a database diagram that visual studio
              said to do. in server explorer there is suppose to be a database
              diagrams folder. Well I do not have one. Is there a way to make one or
              is there an option that I don't have enalbed and that is why I don't
              have a database diagrams folder????

              *** Sent via Developersdex http://www.developersdex.com ***
              Don't just participate in USENET...get rewarded for it!

              Comment

              • Jeff Louie

                #8
                Re: delete command

                Mike...It is pretty hard to figure out what you can see from a
                newsgroup. You should see a database connections icon. If you add a
                database connection you should be able to expand the connection and see
                a database diagrams icon. You should then be able to add a database
                diagram.

                Regards,
                Jeff
                I followed the instructions to make a database diagram that visual
                studiosaid to do. in server explorer there is suppose to be a database
                diagrams folder. Well I do not have one.

                *** Sent via Developersdex http://www.developersdex.com ***
                Don't just participate in USENET...get rewarded for it!

                Comment

                Working...