| Author |
Topic |
|
shelbyoh
Starting Member
14 Posts |
Posted - 2010-02-18 : 15:27:42
|
I am new to work with databases.I have database tables they are Clients, Projects and Tbpacks.Clients columns are Client_ID [int] Primary Key Autoincrement, ClientName.Projects columns Project_ID [int] Primary Key AutoProjectName, and ProjectNumberwith FK Client_ID FK tbpacks_IDTbpacks columns tbpacks_ID [int] Primary Key AutotbpacksName, tbpacksNumber, Divisionon the webpage I have the follow input text boxesClient Name:Project Name:Project Number:tbpacks Name:tbpacks Number:Division:My insert code looks like this.insert Client.ClientName, ProjectProjectName,ProjectNumber,Tbpacks.tbpacksName,Tbpacks.tbpacksNumber,Tbpacks.DivisionINTO Projects, Clients, BidPackageWhere Project.Client_ID = Client.Client_ID ANDProject.Tbpacks_ID = Tbpacks_ID ANDClient.Client_ID = Tbpacks_ID AndTbpacks_Project_ID = Project.Project_ID When I hit the save or save and New Entry |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
shelbyoh
Starting Member
14 Posts |
Posted - 2010-02-18 : 15:44:06
|
| This is Sql server question. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
shelbyoh
Starting Member
14 Posts |
Posted - 2010-02-18 : 16:56:37
|
when a person fill out the form which has the following text boxesClient Name:Project Name:Project Number:tbpacks Name:tbpacks Number:Division:and click on save they data need to insert into the follow column in the database and also when a person go to query the database for a client or project number it list all the people relate to the project number I can do query with joins. I put test data manually and the query works. I have problem creating the proper relationship so when they enter data via the form. I need for it to insert across the tables or should I make all one table. I still would have problems with relationship because I have other table that has to reference the tables.help please. 1)insert Clients values( ClientNameTxtBox ) --a trigger for this table after insert to get @@identity (which is client_id);store it in local a variable @identity12) insert into Tbpacks values ( Name TxtBox , Number TxtBox, Division TxtBox ) --a trigger for this table after insert to get @@identity (which is tbpacks_ID ) ; store it in local a variable @identity2 3) insert into Projects( Client_ID, tbpacks_ID, ProjectName, ProjectNumber) values ( @identity1 , @identity2, ProjectNameTxtBox, ProjectNumberTxtBox ) But I don't know enough about Databases to do so. |
 |
|
|
shelbyoh
Starting Member
14 Posts |
Posted - 2010-02-18 : 16:57:19
|
| I don't know how to set triggers. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-19 : 00:13:13
|
quote: Originally posted by shelbyoh when a person fill out the form which has the following text boxesClient Name:Project Name:Project Number:tbpacks Name:tbpacks Number:Division:and click on save they data need to insert into the follow column in the database and also when a person go to query the database for a client or project number it list all the people relate to the project number I can do query with joins. I put test data manually and the query works. I have problem creating the proper relationship so when they enter data via the form. I need for it to insert across the tables or should I make all one table. I still would have problems with relationship because I have other table that has to reference the tables.help please. 1)insert Clients values( ClientNameTxtBox ) --a trigger for this table after insert to get @@identity (which is client_id);store it in local a variable @identity12) insert into Tbpacks values ( Name TxtBox , Number TxtBox, Division TxtBox ) --a trigger for this table after insert to get @@identity (which is tbpacks_ID ) ; store it in local a variable @identity2 3) insert into Projects( Client_ID, tbpacks_ID, ProjectName, ProjectNumber) values ( @identity1 , @identity2, ProjectNameTxtBox, ProjectNumberTxtBox ) But I don't know enough about Databases to do so.
i think what you need is something likeDECLARE @Client_ID int,@tbpacks_ID intinsert Clients values( @ClientNameTxtBox )SELECT @Client_ID=SCOPE_IDENTITY()insert into Tbpacks values ( @NameTxtBox , @NumberTxtBox, @DivisionTxtBox ) SELECT @tbpacks_ID=SCOPE_IDENTITY()insert into Projects( Client_ID, tbpacks_ID, ProjectName, ProjectNumber) values ( @Client_ID , @tbpacks_ID, @ProjectNameTxtBox, @ProjectNumberTxtBox )... @ProjectNameTxtBox etc are parameters passsed from your form with values------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|