473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.
Jul 21 '05 #1
7 1691
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
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
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


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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sql-db2-dba | last post by:
There are 2 tables A and B with A being the parent of B. Table A ( Col1 varchar(5) Not Null ) Table B ( B_PK varchar(5) Not Null ,
9
by: Toralf Kirsten | last post by:
Hi, we installed db2 v8.1 on red hat linux 9. Unfortunately, the backspace and the delete button doesn't work in the right way. Instead of deleting chars, control characters are inputed. That...
9
by: Melissa | last post by:
What is the code to delete a command button from a form? Can the code be run from the click event of the button to be deleted? Thanks! Melissa
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
5
by: Neil | last post by:
I am getting time-out errors when I try to perform a simple delete on a linked server. The command is: Delete From MyTable Where PKID=12345 I have tried executing this command directly from...
3
by: Kevin M | last post by:
I have one table and have created a form from that table. Also, I have created a delete query. I want to but a button on the form which will delete all records from the table; however, I cannot get...
1
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but...
1
by: jmarcrum | last post by:
Hello all! i have a “monitor-type” program, where my program recognizes my defined "commands”, and executes the given command, or produces an error message that says “unrecognized command”. After...
10
beacon
by: beacon | last post by:
Hi everybody, This is probably going to sound unorthodox, but I have to log records that are deleted...I know, go figure. Anyway, I have a form with a (continuous) subform, and on the subform I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.