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

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

Inserting Values from Multiple Sources into One Table

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

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.

View Complete Post

More Related Resource Links

Infopath 2007 Repeating Table - Multiple Value Column Text - Hiding Rows based on Column text values

Infopath 2007 browser based form Full Trust Example: I have a repeating table (FruitChoice) that has multiple columns. Both drop down list point to sharepoint list data sources. Choose your tree ft. drop down list – 6Ft Choose your Department drop down list - 103 This repeating table is conditional on the drop down values. This works great. Trees     Fruit       Cost   Date Ordered    Date Delivery Department 6Ft        Peaches                                                        103 3Ft        Apples                                                          102 3Ft        Peaches         &

How to INSERT new row values from two different sources, all fields from a table plus one additional

--Loading the single row returned by a table valued function into a temp table works fine like this:
DECLARE @techNumLoop VARCHAR(25)

 Names Varchar(25)
,Item_Count Integer
,Expense_AP MONEY
--,[...20 more fields]
--Loop a while
INSERT @myTemp SELECT * FROM ufn_FindSomeRow(@techNumLoop)
--And finally display a table with one row for each function call
--My Question: what if I would like to also display the value of @techNumLoop passed in to ufn_FindSomeRow?
--Then I add a field to @myTemp to hold it:
 TechNum VARCHAR(25)--added

getting error while inserting values into table in sql server 2005

i have connected to sql server n my connection string is

conn.ConnectionString =

"data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\subi.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

But i am not able to insert values into the table..

am getting sqlexception error.... and msg as invalid object name "staff" as staff is my table name.. before this i had some problem with connection then i cleared that problem then after that this problem occured.. plz guide me on this ... i need to complete my project as soon as possible

Inserting values into multiple tables (using SCOPE_IDENTITY)



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,

Pass Checkboxlist control multiple selected values to SQL table



I wanted to know if it is possible to pass multiple selected values from Checkboxlist to SQL table so each selections goes into separate row in the table.

I tried it using the following code (to pass ShowDate value) but it enters value only if I make one selection. It gives me an error message if I make two selections and try to pass it to SQL.


string showdate = string.Empty;

foreach (ListItem li in BirmShowDates.Items)
            if (li.Selected)
                showdate += li.Value;


            string sql = "INSERT INTO [BShow] ([Single], [UserId], [ShowDate], [Half]) VALUES (@Single, @UserId, @ShowDate, @Half) SELECT [Single], [UserId],  [ShowDate], [Half] FROM [BShow] WHERE [BShow].[ShowDate] = [BShow].[ShowDate]";

            SqlCommand cmd = new SqlCommand(sql, conn);

cmd.Parameters.AddWithValue("@ShowDate", showdate.ToString());


Thank you.

Inserting default values in SQL Table using C#


I have one table which uses newID as default values for field which is primary key and I want to insert either default value or insert new guid values from C# itself.

Please tell how to insert default values in tables using c#

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 deal with NULL values in a SQL table


 Hi all

In order to add/update/delete data from a table I build 2 classes: 1 class containing all the table fields and another class with methods to add/insert/update/delete records. I am learning how to avoid errors when your table must use SQL NULL values. One error is when I call my UPDATE method (see below):

  public void UpdateItem(OcItemConstraintDetails item)
  SqlConnection con = new SqlConnection(connectionString);
  SqlCommand cmd = new SqlCommand("ItemConstraints_Update", con);
  cmd.CommandType = CommandType.StoredProcedure;

  cmd.Parameters.Add(new SqlParameter("@itemConstraintId", SqlDbType.Int, 4));
  cmd.Parameters["@itemConstraintId"].Value = item.ItemConstraintId;

  cmd.Parameters.Add(new SqlParameter("@path", SqlDbType.NVarChar, 150));
  cmd.Parameters["@path"].Value = item.Path;

if you watch the SQL profiler trace you will see that I am passing a value of 'default' ;so that causes me problems.

exec ItemConstraints_Update @itemConstraintId=1,@path=default

With that said, what are the best practices when your SQL table accepts NULL values and when:
- you are passing an empty value to your stored procedure;

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.



Model Binding the values in an HTML Table back to Controller / Model


Currently, I am working with ASP.NET MVC1 and am still learning about Model Binding and how values from a View are passed back to the Controller / Model. Specifically, I want take an existing Model, create a Table and populate the Rows of the Table, allow the user to edit some fields and pass it back.

In my example, I have a Class called "Ingredient" which has 4 public accessors:  Name, Barcode, Amount, and Unit

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcACE.DomainModel.Entities.Ingredient>>" %>

<% using (Html.BeginForm("SubmitOrder","MyController"))
{ %>

<% if (Model != null)
foreach (var item in Model)
{ %>
<td><%= Html.Encode(item.Name)%></td>
<td><%= Html.Encode(item.Barcode)%></

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.

Using the single *.rpt file with multiple data sources


I've created a set of CrystalReports (*.rpt files) for an ASP.NET web app on a development server. I call each report using the following code:

protected void BTN_RunReport_Click(object sender, ImageClickEventArgs e)
CrystalReportViewer_ClientLetter.Visible = true;

ConnectionInfo con = new ConnectionInfo();
con.ServerName = Constants.ServerIP;
con.DatabaseName = Constants.DatabaseName;
con.UserID = Constants.UserID;
con.Password = Constants.Password;

CrystalReportViewer_ClientLetter.ReportSource = Server.MapPath(Constants.ClientLetters);
ParameterFields parameter = CrystalReportViewer_ClientLetter.ParameterFieldInfo;
ParameterField batchdate = new ParameterField();
batchdate.Name = "@BatchDate";
ParameterDiscreteValue batchdate_value = new ParameterDiscreteValue();
batchdate_value.Value = Convert.ToDateTime(txtBatchDate.Text);

foreach (TableLogOnInfo tlf in CrystalReportViewer_ClientLetter.LogOnInfo)
tlf.ConnectionInfo = con;

two temperory table values from sql to a crystal report


in a crystal report ,  i used stored procedure name to display the fields.my problem is,  in the procedure i selected the fields from two temperary tables.but in vs 2005 field explorer showing only the fields from the first temperory table.y the second temperry table fields are not displaying?

i need two temporary table values .In sql tempo table query like as follows

Select  * #TmpSummrep1.

Select  * #TmpSummrep2

all fields from #TmpSummrep1 available in field explorer.

my procedure is running without any errors.

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
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