I make many to many relationship in erd diagram in sql server 2005 between ca and driver as following
car table
driver table
car_driver table.
I need to make fleet management program. When I make forms in windows form are i make car form driver form car_driver form When i insert data are creating three forms each form insert to related tables
car table car form
driver table driver form
car_driver table car_driver form

please help me

Well, you can do one of the following:
1) Create a SQL Stored Proc to handle this for you
2) Use Linq (or nHibernate) to handle this for you
3) Do it yourself

If you do it yourself, you will need to do something like (this is Psuedocode):
INSERT INTO CAR (Make, Model, Year) VALUES ('Pontiac', 'Firebird', '1973')
and using SQLCommand you can return the Primary Key (probably CarId) from your Car table, then:
INSERT INTO DRIVER (Name, LicenseNo) VALUES ('Dr Who', 'baDWolf')
and again, use the SQLCommand ExecuteNonQuery to return the DriverId
and finally:
INSERT INTO CarToDriver(CarId, DriverId) VALUES (CarId, DriverId)

A storedproc can do this for you too, I can help you with that if that is the way you want to go. I, however, suggest nHibernate or Linq as that relationship can be handled without any coding from you.

Hope this helps,
Mark A. Malo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.