Regarding the Query to save the Ids of the edited names from different tables into a single table.

Here with the below query iam binding my gridview with industry name,company name,Plant Name,Group Name related to the IDs in Audit table.

Select Aud.Ad_ID_PK,Aud.Audit_Name,Ind.Industry_Name,Cmp.Company_Name,Pla.Plant_Name,Gr.Groups_Name,Aud.Audit_Started_On,Aud.Audit_Scheduledto,Aud.Audit_Created_On from

Industry Ind,

Company Cmp,

Plant Pla,

Groups Gr,

Audits Aud

where Ind.Ind_Id_PK =Aud.Audit_Industry and

Cmp.Cmp_ID_PK =Aud.Audit_Company and

Pla.Pl_ID_PK =Aud.Audit_Plant and

Gr.G_ID_PK =Aud.Audit_Group and

Ad_ID_PK in (select Ad_ID_PK from Audits)

Now i want to edit these names.

when i click on edit in gridview these names will be filled into textboxes and when i change the names it should compare the name with particular tables and should get the Id of that and store in Audits table.

For example:

i have this data in my audits table:

Commercial83312 2 2 2 1

Here Commercial83312 is ID of that Audit and 2,2,2,1 are the Industry,Company,Plant and group Ids for that particular audit.In the front end i can see the names of this particular IDs.

when i edit the industry name in the UI it must check the name with industry table and get the ID of the changed name and store it in audit table.

so the data may be changed in audits table as :

Commercial83312 4 2 2 1

 

so here the industry ID is changed

I need the stored procedure for this.

please help me,its very urgent...


Thanks Prameela
0
prameelachandra
3/8/2008 12:17:20 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

4 Replies
669 Views

Similar Articles

[PageSpeed] 49
Get it on Google Play
Get it on Apple App Store

in your stored procedure, first find the id of that industry matched with the name.

then with the id, update the record

eg:

declare @IndId int

set @INdId = (select IndId from Industries where name = your industry name)

update audittable set IndId = @INdId  where auditid = Recordid you r edititng

 

But , its better if u place a ddl in gridview  for industries in edittemplate and ask the user to select the industry from that ddl.


Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.
0
ramireddyindia
3/8/2008 1:19:57 PM

Triggers are best for Audit tables. Triggers are procedure on MSSQL that is executed when someone edits, adds or deletes a record from the table. Triggers has inserted and deleted object that can be used to access the last updates on the record before saving the new record. Here is the Syntax:

 
 
CREATE TRIGGER [Trigger_all] ON [dbo].[SampleTable]
For INSERT, UPDATE, DELETE
AS
IF EXISTS(SELECT * FROM INSERTED) AND EXISTS(SELECT * FROM DELETED)
BEGIN
--procedure for Update 
END
ELSE IF EXISTS(SELECT * FROM INSERTED)

BEGIN
--Procedure for insert 
END

ELSE IF EXISTS(SELECT * FROM DELETED)
BEGIN
--Procedure for delete
END
 

 I cannot go in details on this but atleast you have something to start on your research.

I'll try to add this topic on my Blog and will tell you if I have made it in this thread 


 


Vincent Calaor
Software Engineer
Philippines

[Please click "mark as answer" If my reply helps you]
Learn more from LearnITFromVince.BlogSpot.com
0
VinceArcher23
3/8/2008 3:20:58 PM

Simple explanation on using trigger at LearnFromVince. you can visit that to check.


Vincent Calaor
Software Engineer
Philippines

[Please click "mark as answer" If my reply helps you]
Learn more from LearnITFromVince.BlogSpot.com
0
VinceArcher23
3/8/2008 3:33:33 PM
Thanks ramireddy,its working....
Thanks Prameela
0
prameelachandra
3/10/2008 8:31:47 AM
Reply:

Similar Artilces:

trying to save editted textbox value in table but original value saves instead
This program gets the values of A and B passed in. They are for table columns DXID and CODE. The textbox GET1 is initialized to B when the page is loaded. When I type another value in GET1 and try to save it, the original initialized value gets saved and not the new value I just typed in. A literal value, like "222" saves but the new GET1.TEXT doesn't. Why is this?How do I make this work right?<%@ page language="vb" %><%@ reference page="try7.aspx" %><% @import namespace="system...

SQL queries in .NET; table name prefix not added
When I create SQL queries with multiple tables in .NET the datasets that are generated do have only the column names. The table name is not included. That makes it very hard to find the right column. In PowerBuilder the datawindows are created with a name as <table name>_<column name>. For example. I do have two tables. Both tables do have a column ID and Name. *Employee* ID, Name etc. Dep_id etc. *Department* ID, Name, etc. With this SQL statement: SELECT Employees.ID, Department.ID FROM Employees INNER JOIN Departments ON Employees.dep_id = Departme...

Regarding Select query for a table which has relation with all other table..
Hi,I need select query to display all the tables which has relation to particular table. can anyone help me.. Remember to click “Mark as Answer” on the post that helps you. Thank you!Always,Naveen..  select so.name from sysforeignkeys sfinner join sysobjects so on so.id = sf.fkeyidinner join sysobjects so1 on so1.id = sf.rkeyidwhere so1.name = 'cu_userinfo' or so.name = 'cu_userinfo'unionselect so1.name from sysforeignkeys sfinner join sysobjects so on so.id = sf.fkeyidinner join sysobjects so1 on so1.id = sf.rkeyidwhere so1.name = 'cu_userinfo' or so.name...

selecting columns from different tables into a single table
I want to select columns from different tables into a single table...Not sure if a temp table is suited for this and if so how I should implement it (NOTE: this query will be executed many times by different users at the same time, so I'd rather avoid temp tables!)I have:TABLE1idfirstnamedescriptioncreatedateTABLE2idcarnamespecificationsimportdateNow, I want a resultset that has the columns (columns from other tables from which the values should be retreived are behind the desired columns):id  (TABLE1.id, TABLE2.id)title (TABLE1.firstname , TABLE2.carname)description (TABLE1.descrip...

What is the difference between #table and ##table
If i create a ##table using my stored procedure, I can do the select * from ##table but when i created the #table using the stored procedure and tried to do the select * from #table I am getting the error message invalid object #table that means it is going out of scope. But if i create the ##table, will that table going to remain in the database even until i drop the ##table or it gets dropped when i close the database connection. Thank you very much. -Raj There are two types of temporary tables: Local temporary tables The names of these tables begin with one n...

Difference between #table and # # Table?
If i create a ##table using my stored procedure, I can do the select * from ##table but when i created the #table using the stored procedure and tried to do the select * from #table I am getting the error message invalid object #table that means it is going out of scope. But if i create the ##table, will that table going to remain in the database even until i drop the ##table or it gets dropped when i close the database connection. Thank you very much. -Raj From SQL Server Books OnLine: There are two types of temporary tables: Local temporary tables Th...

I have created a table Table with name as Varchar and id as int. Now i have started inserting the rows like, insert into Table values ('arun',20).
I have created a table Table with name as Varchar and id as int. Now i have started inserting the rows like, insert into Table values ('arun',20).Yes i have inserted a row in the table. Now i have got the values " arun's ", 50.                 insert into Table values('arun's',20)  My sqlserver is giving me an error instead of inserting the row. How will you solve this problem?    The direct answer to your question is: You insert it like this:   ...

how to combine tables from different select statements in to single table
hi, i want to get tables from different select statement in to single table.is this possiblehappy codingLive and Let Live  you can Use UNION operator in sqlselect  <your columnlist> from tablename1unionselect  <your columnlist> from tablename2 or in ASP.Net, you can use Merge function.http://www.codersource.net/published/view/298/dataset_features_in_asp_net.aspx Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.  use union between two select statements, but for this both statements column structure should be ...

The Microsoft Jet database engine cannot find the input table or query 'table name'. Make sure it exists and that its name is spelled correctly.
I have an access database linked to the contacts folder of outlook. I used the access link table wizard to do so. I am able to view the table in access. However, when Im trying to access the table in my .net application, i get: The Microsoft Jet database engine cannot find the input table or query 'IPContacts'. Make sure it exists and that its name is spelled correctly.  Where my table is called IPContacts. The outlook contacts folder is part of our excahnger server. When I tried to link directly to the exchange server, Access crashed. THe only look that worked was through outlook...

SQL Msg 107 Error... The column prefix does not match with a table name or alias name used in the query.
Can someone please answer a problem that I've run into.  I know that it's probably something stupid.  I keep getting this error:Server: Msg 107, Level 16, State 3, Line 1The column prefix 'vFirstTimeEntered' does not match with a table name or alias name used in the query.Here is my query:-----------------------------------------------------------------Update  TimeSheetSectionSet TimesheetSection.SECSTARTDT = vFirstTimeEntered.schlstuidWhere timesheetsection.schlstuid = vFirstTimeEntered.schlstuid AND timesheetsection.sectionid = vFirstTimeEntered.sectionid AND&...

line break problem, I used the DetailsView to save an article to sql table, then I use label to read out from sql table, but couldn't break line.
Here is my code: <asp:Label ID="Label" runat="server" Text='<%# Eval("ServiceBody") %>'></asp:Label>Life is not easy but beautiful! use <asp:Label ID="Label" style="word-wrap:normal" runat="server" Text='<%# Eval("ServiceBody") %>'></asp:Label> and fix the widht of the colum in which you have placed this lable. like width=150px    If this post helps you, please mark it as Answer.Cheers,Muhammad Rizwan JavedSr .Net DeveloperAim 168, Dubai, UAE. Use ...

SQL Query Problem - Joining a table to another table
 Ok i'm trying to build a sql query that pulls two names of users from 1 user table to matchup two users (instructor and teaching assistant) in the same record of another table but can't get it right.  Below is a simplified version of what i'm trying to do.  I have a table "Courses" that stores the ID of an Instructor and a Teaching Assistant assigned to the course.  Both the instructor name and teaching assistant name are pulled from the same table (as teaching assistants could technically be instructors as well).  The problem is i can't cr...

Tables?! Why Tables?!
Bit random...but why does everything have to be rendered as a table?  It's starting to get quite annoying.  Formview - does this need to be a table?  the Menu??  Wouldn't it make sense to allow the option to...say...not render a Menu as a table?  Am I the only one that thinks this or are there others?  www.internetgeeks.co.ukwww.norwichbookclub.co.uk You can use CSS Adapters to create your own adapters to override how the controls render it self. In the next version of ASP.Net, you will probably have more flexibility to specify the surrounding elements of th...

Adding Rows from different Data table to a single Data Table
Hi, I have 3 data tables say dt1, dt2, dt3. None of the tables have any relation with each other. Now i my requirement is to merge all these 3 datatables into 1.  But, i dont want it into different rows. Means to say, record from 1st, 2nd and 3rd table shud be merged as a single row in resultant datatable. Below example explains better Table 1 : 123 abc 890 Table 2 : rew 234 Table 3: sdfsd 234 dfg 45645 Now Resultant table shud be :  123 abc 890 rew 234 sdfsd 234 dfg 45645 Any help is appreciated :) Thanks in advance   If you keep your feet firmly on ...

Web resources about - Regarding the Query to save the Ids of the edited names from different tables into a single table. - asp.net.sql-datasource

University Plans Tribute to Officer Killed in Planned Parenthood Shooting
University Plans Tribute to Officer Killed in Planned Parenthood Shooting

‘Fantastic Beasts’ Stars Afraid To Give Away Spoilers: Here’s What’s Been Revealed So Far
Fantastic Beasts and Where to Find Them is currently being filmed in the UK, but they have run into a bit of a snag. It seems that while they ...

It Is Time To Rethink Donald Trump’s Candidacy
From the very beginning of his campaign (and perhaps before), Donald Trump has gathered a following of supporters using his blunt, no-holds-barred ...

Carson visiting Syrian refugees in Jordan
WASHINGTON (AP) — Republican presidential candidate Ben Carson is in the Middle East this weekend to meet with Syrian refugees.

Russia should nuke enemy number one Turkey as tensions continue to escalate - Latest News - Breaking ...
RUSSIA is ready to "use nuclear weapons on enemy number one" Turkey, one of the country's leading politicians has announced.

Pope Francis visits Ugandan shrine amid gay rights debate
Reuters Pope Francis visits Ugandan shrine amid gay rights debate Reuters NAMUGONGO, Uganda Pope Francis traveled to Uganda's holiest shrine ...

Pro tip: Access all your cloud accounts from one location on Android
Tired of navigating between various cloud apps on your Android device? If so, Jack Wallen shows how to centralize all your cloud accounts with ...

White House Christmas Tree Arrives, No One Really Sure When First Presidential Tree Appeared
First lady Michelle Obama received the 2015 Christmas tree at the White House on Friday, according to USA Today . The Fraser fir is said to be ...

‘NFL On CBS’ Snags Record Thanksgiving Day Ratings
CBS Sports' Thanksgiving Day matchup of Carolina vs. Dallas (4:31-7:49 PM, ET), was the most-watched Thanksgiving Day game in 20 years for the ...

California may be a leader on climate change, but it still has plenty of work to do
When Gov. Jerry Brown arrives in Paris next week for a major international conference on climate change, he will showcase one of the world’s ...

Resources last updated: 11/28/2015 12:54:10 PM