.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Inserting values into multiple tables (using SCOPE_IDENTITY)

Posted By:      Posted Date: October 09, 2010    Points: 0   Category :ASP.Net


I have problem inserting multiple values into multiple tables from web form. I have a web form for creating article (from table Clanak) and in the end there is a textbox (txtTagovi) that is used for inserting Tags (in table Tagovi) which are separated by ";".

These are the tables: Clanak (idClanak,...), Tagovi (idTag, naziv) and the cross reference table ClanakTagovi (idClanakTagovi, idClanak, idTag)

There are multiple problems...

The first one is how to get the SCOPE_IDENTITY (without stored procedures) of the last inserted Article (from table Clanak) without getting the following error: "Incorrect syntax near ')'." I will comment the part of the code that has this problem.

The second problem is implementation of the tags. I am aware that if my current solution gets corrected it won't be what I originally wanted because my idea was to add tags and if there are similar tags I wanted them to get the same ID, without having duplicates in table (that's why I need Clanak Tagovi table).

For example:

Clanak {(idClanak=1,...),(idClanak=2,...),...}, 

Tagovi {(idTag=1, naziv="Tag1"), (idTag=2, naziv="Tag2"), (idTag=3, naziv="Tag3"),..} , 

ClanakTagovi {(idClanakTagovi=1, idClanak=1, idTag=1), (idClanakTagovi=2, idClanak=1, idTag=2), (idClanakTagovi=3,

View Complete Post

More Related Resource Links

fetching values from multiple tables to show on crystal report

Can somebody guide me to make crystal report showing values from multiple tables?

Inserting data in multiple tables C#


Hi! Is there any way I could insert a record in multiple tables using only a single post? So far I could insert records in a single table using formsview and detailsview but it only allow me to insert records in one table. I have 4 tables and each has foreign keys and dependencies with other tables.

Any help will be appreciated.


Inserting Values from Multiple Sources into One Table


Hi, I'd like to insert a single integer value from tables on multiple databases into a single table row that includes the date. Any ideas on how to structure this query? (Each value represent a distinct count of user names that have used an application for a given day. The log tables are located on multiple databases).

Right now I have an INSERT INTO statement that inserts the date and a count from a single source into a row, but I'm having trouble understanding how to insert the values from all sources into a single row with one query? UNION? Not sure...

Any advice would be greatly appreciated.

values from one dataadapter to multiple tables in a dataset through foreach loop



 How can i fill the values from one dataadapter to multiple tables in a dataset...ie,the adapter is fetching values through foreach loop...i want to take that values into different tables of one dataset....How to do this...Hope anyone will help me....

Thanks in advance

jquery autocomplete multiple values


i got some samples and i did autocomplete using jquery , its working well for single input values

but i need to pass multiples values after one by one in the textbox. Is it possible to pass multiple

values in the textbox for autocomplete in jquery in asp.net?


merging multiple tables in a single dataset to single table


 i have a stored procedure which returns three tables to a dataset ..... now i need to merge all three tables to a single table from d same dataset 

like dataset1 has table1 table2 and table3 .... i want all the three tabels to be merged into dataset1 itself .... instead of three diffrent tables so that i can show all three table data in a single datagrid  as a compact data and combination of 3 tables from d single dataset.....

can some1 help me please.....

How to store and retrieve multiple values in a single session variable .


I want to store employee name,designation and department in session variable and
retrieve in another page how to do this.

Configure BDC column to have multiple values selected


How do I Configure BDC column to have multiple values selected and make multiple entities data available in the same column.  Currently it supports only single value for an item.  This requirement is crucial need some solution immediately.

BDC Column with Ability to Select Multiple Values


Use Case:

We are creating a storage location for technical product articles. These will be SharePoint publishing pages. Each page will have metadata assigned to it to make it searchable by properties. The possible values for one of the columns (Part Number) could potentially be sourced by our ERP system. I'd like to do this to eliminate the possibility of free-text entry errors, but there are probably over 10,000 parts so a drop-down list isn't feasible.


Ideal Situation:

The end user enters the part number and clicks a button to verify it against a BDC entry from our ERP system. If they weren't sure on the part number they needed, they could do a lookup from that metadata entry screen. They'd need to have the option to add multiple part numbers as one technical product article could reference multiple part numbers.



Is BDC an option for all of this or am I looking at a custom metadata solution? I thought I heard along the way that BDC only supported one value choice, but I couldn't find a verification for that in the forums.



How do you create a custom BDC data field that allows for multiple selected values?

I need help creating a custom data field using the BDC column as a base.  We need to allow for multiple selected values instead of just a single one.  I can't find anything on the net which shows how to do this.

Multiple values in where clause

How do I use the same statement to retrieve 2 values ABCD and XYZ? Now I get only one value ABCD - now I want only 2 values ABCD and XYZ. I'm looking for syntax SELECT [Measures].MEMBERS ON COLUMNS, NON EMPTY [0VENDOR].[LEVEL01].MEMBERS DIMENSION PROPERTIES [0VENDOR].[20VENDOR] ON ROWS FROM [OPOMCHS0/ZQT_GPO_PO_CHNG_REP_SUMM_3]WHERE[0VENDOR].[ABCD] Any help is appreciated

Excel 2007 Filter on multiple values

Hi Everyone,How do I use Excel 2007 Pivot Table's label filters/value filters to filter with multiple conditions? for example, I want to get all customers with customer name start with "G" and doesn't include "E" and with measure>100 and measure between 50-60.Regards,George

SUM col from multiple tables

I am trying to SUM a column from each of 3 tables, where an ID field is the same in each table and the date range is the same also It would look something like this: table1      table2      table3      table4  amt         amt         amt         t4ID  ID           ID           ID  date        date        date SELECT SUM(t1.amt),SUM(t2.amt),SUM(t3.amt) WHERE (each table).ID = @t4ID AND (each table).date BETWEEN @date1 AND @date2 the t4ID, date1 and date2 will be chosen by the user from controls and supplied to the statement via a parameter array. I have tried many variations ( with more to go) to send 1 @t4ID parameter, for example, and use that in all 3 tables (same with the dates). Any help to nudge me in the right direction would be appreciated. Thanks

Multiple Values Grouping

Hi all, Please could you help to get multiple values grouping implemented properly? I need to group a set of instances by groups. Some instances belong to multiple groups. I have used listbox and GroupDescriptions for that. Those instances that belong to several groups are shown as duplicates (like in Outlook when letter belongs to several categories). But selection of items becomes buggy. Even if ListBox SelectionMode is Single, it is possible to get two different items (not duplicates) to be selected simultaniously. Please use my code example. Launch application Put check into checkbox to apply grouping. Select Potato(Tasty). Select Tomato(Round). Select Potato(Tasty). Select Tomato(Round). Notice that Potato(Tasty) and Tomato(Round) are selected simultaniously.   <Window x:Class="GroupingSample.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Grouping Sample" Width="220" Height="550"> <StackPanel> <TextBlock Margin="12,5,5,0" FontSize="20" Text="My Task List"/> <CheckBox Margin="10,5,5,10" Checked="AddGrouping" Unchecked="RemoveGrouping">Group by task type</CheckBox> <ListBox Margin="10&qu

DropDownList to display values from Two Tables - bold sub heading and normal Text

Hello I hope I am not asking simple one.  SUPPORT SERVICES<     Computing Service    Library or Data Engineering    Civil Engineering    Electrical Engineering  I have the data to display in a DropDownList control shown as above. There is a distinct category Type(example Support Services) and Category Name i.e., Computing Services. I do not want to hard code the values into DropDownList control. I like to get the data from database to display as shown in above Table. Note that Category Type should be displayed in Bold and Category Name in normal Text. Question: In order to achieve the above, 1. How many database Tables and relationships between them  2. Query the data to display in the above format in drop down 3. how should be the code behind i.e, DataTextValue and DataValueField for DropDownList. Please provide with useful code snippets or references. Thanks,

Rename a column in multiple Tables using sp_rename

Hi,Any work around for the below issue?Originally "LoadDate" column (see below scripts) was there both in tables DIM_Table_1 and DIM_Table_2According to change in requirement, LoadDate in both the tables to be chnged to LOAD_DATE. It has to be done through script-----------------EXEC sp_rename 'dbo.DIM_Table_1.LoadDate',     'LOAD_DATE', 'COLUMN'         -- Successfully executedEXEC sp_rename 'dbo.DIM_Table_2.LoadDate',     'LOAD_DATE', 'COLUMN'         -- Error: See below Error: The new name 'LOAD_DATE' is already in use as a COLUMN name and would cause a duplicate that is not permitted.-----------------

Can i write stored proc for the two queries, truncating and inserting two different tables?

Hi All, I have two queries below. trying to write stored proc so i can combine these queries so i can use only one execute sql task. both the queries are truncating and inserting records in two different tables. QUERY 1 à   truncate table [PlanFinder].[InvalidAwps] go   INSERT INTO [PlanFinder].[InvalidAwps]     (Ndc, AwpUnitCost)     SELECT DISTINCT P.Ndc Ndc, A.Price AwpUnitCost     FROM         PlanFinder.PlanFinder.HpmsFormulary P         LEFT JOIN (SELECT Ndc, Price FROM MHSQL01D.Drug.FdbPricing.vNdcPrices                     WHERE PriceTypeCode = '01' AND CurrentFlag = 1) A     ON P.Ndc = A.Ndc      WHERE (A.Ndc IS NULL OR A.Price <= 0 OR A.Price IS NULL)     AND p.Ndc IS NOT NULL --------------------------------------------------------- Query 2 à   truncate table [PlanFinder].[MissingNdcs] go   INSERT INTO [PlanFinder].[MissingNdcs]     (Ndc)     SELECT DISTINCT Ndc     FROM         PlanFinder.InvalidAwps       WHERE AwpUnitCost IS NULL  Thanks a
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend