By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,359 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,359 IT Pros & Developers. It's quick & easy.

delete command

P: n/a
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.
Jul 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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!
Jul 21 '05 #2

P: n/a
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
Jul 21 '05 #3

P: n/a
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" <mi******@comcast.net> wrote in message
news:M5********************@comcast.com...
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.

Jul 21 '05 #4

P: n/a


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!
Jul 21 '05 #5

P: n/a
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!
Jul 21 '05 #6

P: n/a
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!
Jul 21 '05 #7

P: n/a
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!
Jul 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.