473,473 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1696
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.