DataSource Controls :: Copy Data From One Table And Insert With Extra Values?

Jan 27, 2010

Is there a way to copy a row from one table and insert to another but at the same time insert extra values to destination table?Let's say source table Item has values:

ItemID
ItemType
ItemProducer
ItemModel

Destination table ItemHist:

ItemID
ChangeDate
ChangeReason
ChangedBy
ItemType
ItemProducer
ItemModel

I want to copy row from source table where itemid is 25, insert it into destination table and add extra values: ChangeDate, ChangeReason, ChangedBy. I tried:

INSERT INTO ItemHist (ItemID, ChangeDate, ChangeReason, ChangedBy, ItemType, ItemModel) VALUES (ItemHist.ChangeDate=GetDate(), ItemHist.ChangeReason="why not", ItemHist.ChangedBy="me")
SELECT ItemID, ItemType, ItemProducer, ItemModel FROM Item WHERE ItemId=25

but obviously it didn't work ("The name 'ChangeDate' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.").

View 4 Replies


Similar Messages:

DataSource Controls :: Insert Values From One Table Into Another?

Jun 30, 2010

I have a table with a lot of records - it has a column called CallID I have another table with no records, but one that also has a CallID column I want to insert all the values from the CallID column in the first table into the CallID column of the second table.

View 6 Replies

DataSource Controls :: Sqldatasource Insert Method - Copy Data To The Other Datasource By Selecting Checkbox

Feb 25, 2010

i have two sqldatasource controls. one i use to display data in textbox's ,filter'd by a select parameter in page behind code. Once checked, i want to copy this data to the other datasource ,by selecting checkbox.Then display this data in detailsview control.

At present the two datasource controls declared , render data to the page simultaneously during pageload. I want to first check data in textbox's from first source, before second datasource is rendered to screen. note, both are filtered by a page variable. i wish to leave the textbox datasource control in situ, as other controls and code depend on it.The other detailsview datasource is my problem?

View 1 Replies

DataSource Controls :: Insert Comma Separated Values Into Multiple Columns Table?

Mar 22, 2010

I've requirement where user can enter multiple columns like first name, lastname, email, age, sex fields and insert them into database.on my frontend aspx page, i'll be showing a single row initially with 5 text boxes(first name, lastname, email, age, sex) and a button to add more columns. when user clicks on add more, another 5 textboxes will be shown and then i'll be taking 5 + 5 (textbox values) and comma seperate them and need to insert into a table with primary auto increment key ID and the remaining 5 columns(firstname, lastname, email, age, sex). I previously worked on the same requirmeent but with only single column. Now i need to insert for 5 columns, How can i do this? Below is my stored proc which i used for single column insertion.

[Code]....

View 12 Replies

DataSource Controls :: Copy Data From Table Into File External To The Db?

Jun 10, 2010

I want to export the table and all the data to a file outside the db. Then I want to detach this db, attach a different db with the same table, and reimport the table data from the file.

I thought you could create a table with :

select *
into table IN externaldb
from table

What is the proper syntax for this? I got an invalid path error. I just want to create the file on mu local C root.

View 2 Replies

DataSource Controls :: TableAdapterManager.UpdateAll Shows Foreign Key Error When Insert Values To Master And Child Table

Mar 18, 2010

I am trying to use the TableApapterManager.UpdateAll to insert values to master and child table. I had set the relation to cascade for update in the dataset and the HierarchicalUpdate to true. But stil when I run TableApapterManager.UpdateAll(dataset), I get a foriegn key violation error. Following is the code I used:

int ID;
DAL.Datasets.dsMembers.MembersRow rwMem = m_dsMembers.Members.NewMembersRow();
rwMem.u_name = mem.Name;
m_dsMembers.Members.AddMembersRow(rwMem);
DAL.Datasets.dsMembers.MemPhonesRow rwmemphn = null;
rwmemphn = m_dsMembers.MemPhones.NewMemPhonesRow();
rwmemphn.u_memberid = ID;
rwmemphn.u_phn = "test";
m_dsMembers.MemPhones.AddMemPhonesRow(rwmemphn);
m_adpMgr.UpdateAll(m_dsMembers);
return ID;

The error I get is "The INSERT statement conflicted with the FOREIGN KEY constraint "FK_MemPhones_Members". The conflict occurred in database "Family", table "dbo.Members", column 'i_memeberid'.
The statement has been terminated."

View 2 Replies

DataSource Controls :: Copy The Data Of The Excel Sheet To The Sqlserver Table?

Feb 18, 2010

i am Using sql server 2005. i want to copy the data of the excel file to the table.

i wrote the query like :

INSERT INTO test(empId,empName,empMailId,empContactNo)
SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C: estExcel.xls',
'SELECT * FROM [Sheet1$]')

got the following error :

SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.

then did this

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO

again am trying the same above query ,now am getting the following error:

Msg 7399, Level 16, State 1, Line 1 The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" reported an error. The provider did not give any information about the error. Msg 7303, Level 16, State 1, Line 1 Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

i want to copy the data of the excel sheet to the table.

View 2 Replies

DataSource Controls :: Way To Retrieve Data From A Table, Modify And Insert It Into Another Table

Jun 13, 2010

Basically i deal with two tables.i have a table T1 of the following format:id company_name i need to read this data and create a table T2 as followsi wrote the following code. it worked fine for retrieving data and modification but fails to insert the modified data into the 2nd table.the error is, it does not recognise the value for @token

ArrayList dynarr=new ArrayList(); // global variable
protected void Button2_Click(object sender, EventArgs e)
{
int row = 1; int i;
string strcmd = null;
string Connection = "Data Source=....";
SqlConnection conn = new SqlConnection(Connection);
string str = "select company_name from T1 where ID=@ID";
[code]...

View 2 Replies

DataSource Controls :: How To Copy One Table To Another Table In Dataset Using C#

Jun 18, 2010

how to copy from one table to another table in dataset using c#

View 2 Replies

Forms Data Controls :: How To Insert Several Checkbox Values Into A Single Column In The Table

Feb 7, 2011

i have a form with several checkboxes....i want to insert the selected checkbox values in to a single column in the sql database..

View 4 Replies

Can Insert Rows To Table A Based On Values In Table B By A Single INSERT Statement

Dec 7, 2010

I am doing a data warehouse project.I have two tables tblA (id, type) and tblB(city, no_crimes, type).I want to create (insert) a number of rows based on the value of no_crimes.For Example, in tblB(Leeds, 2000, murder). SO, I need to insert 2000 rows into tblA by a single INSERT statement (not 2000 statements).

View 3 Replies

DataSource Controls :: Insert Texfields Data In To Sql Database Table?

Feb 11, 2010

the code to insert the data from asp.net application to sql database table

like user registration form filelds in sql db table

View 3 Replies

DataSource Controls :: Select A Record From A Table And Insert Into B Table Using Linq?

Jun 29, 2010

how can i select a record from A table and insert into B table using linq?

View 2 Replies

DataSource Controls :: How To Insert StudentId From One Table Into Its Foreign Key In Another Table

Jun 9, 2010

I have two tables - Student and Advert.

I want to do the following;

1. Student is logged into their account (session is authenticated)

2. StudentID is primary key for that table, it is a foreign key for table Advert

3. When student is logged in, they create advert

What I want is their student Id to be input into the advert table when this new advert is created. How is this possible?

View 1 Replies

DataSource Controls :: Unable To Select And Insert Data In Mapping Table Using Entity Framework

Jan 18, 2010

I have three table like above, table C is mapping table which has foreign key of Table A and B.How can i select and insert data in Table C using Entity Frame Work?

View 2 Replies

SQL Server :: Copy Table Values From One Database To Another?

Oct 24, 2010

I am stuck with an issue. I have around 200 rows in a table with a particular database. I want to copy those values to another table in a different database.

View 3 Replies

DataSource Controls :: How To Read Data Values Of A Table Using Loop In Sqlserver

Feb 10, 2010

I am using vs2008, Sqlserver2008.

my table: PostGL having data like thi

AutoIdx TxDate Id AccountLink Description Debit Credit
3 2010-01-22 JL 2 bcb 0 35.09
5 2010-01-28 JL 2 g 3.51 0

select AutoIdx,TxDate,Id,AccountLink,Description,Debit,Credit,(Debit-Credit) as Actual from PostGL where Id='JL' and AccountLink=2

AutoIdx TxDate Id AccountLink Description Debit Credit Actual
3 2010-01-22 JL 2 bcb 0 35.09 -35.09
5 2010-01-28 JL 2 g 3.51 0 3.51

I am trying in view like this

declare @cnt int
declare @i int
set @budget=20
set @cnt= (select COUNT(*) from PostGL where AccountLink=2 )
set @i=1
WHILE (@i<=@cnt )
BEGIN
set @tdebit=??

END

I am taking count the no of rows having AccountLink=2
I need to read all debit,credit and add all debit into totaldebit,all credit into totalcredit independently from table.
then i need to show the totaldiff as Actual.
i need ....totaldiff=totaldebit-totalcredit

View 3 Replies

DataSource Controls :: Insert Images Into SQL Table?

May 15, 2010

I want to insert a bunch of images into a SQL table I made.

Not sure how to get the data into a Image data Type. It's not like typing in a date or text.

Can is be done manually or must it use an insert statement?

If insert how is best done?

simple Table
ImageData Image
ImageID Int
ImageName nvarchar
ImageDescription nvarchar

Thay are all in the same folder

View 5 Replies

DataSource Controls :: SQL Insert With Server Default Values

Apr 19, 2010

I'm trying to execute a simple insert statement with the GUID and timestamp populated by default from the server. I have both of their default values set as (newid()) and (getutcdate()) respectively in SQL server. However, I receive the error when I try and execute the command "Insert Error: column name or number of supplied values does not match table definition". How do I construct my sql insert so my id and timestamp columns use their default values as assigned in sql server?

[Code]....

View 3 Replies

DataSource Controls :: Get Values From Wizard And Insert It To Database?

Dec 30, 2010

Im a PHP programmer and now I'm try to do some work with ASP.NET but I got into trouble just in the first stage of my application.Can Anyone help me find out how to get the user inserted values from CreateUserWizard and insert it to sql database. I have implemented using the following codes, but I keep getting the error message "The name 'identifier' does not exist in the current context". I have tried different approaches but any of them worked.Code:.aspx

<%@&nbsp;Page&nbsp;Title="Register"&nbsp;Language="C#"&nbsp;MasterPageFile="~/Site.master"&nbsp;AutoEventWireup="true"&nbsp;&nbsp;&nbsp;&nbsp;CodeBehind="Register.aspx.cs"&nbsp;Inherits="PaperReviewSystem.Account.Registe

[code]...

View 2 Replies

DataSource Controls :: How To Insert Multiple Entries In A Table

Mar 24, 2010

An option to add a range of computers based on tag numbers, for instance, user input 800101 and 800110 would add computers SYS800101, SYS800102, SYS800103, SYS 800104, SYS800105, SYS800106, SYS800107, SYS800108, SYS800109, and SYS800110. Currently the app adds a single computer at a time.

Here I am using ASP.NET using C# and my backend in active directory.

View 12 Replies

DataSource Controls :: Insert List To Database Table?

Jul 4, 2010

how can I insert a list (of int) to table?

View 1 Replies

DataSource Controls :: LinqDataSource.Insert(values) Versus InsertParameters

May 26, 2010

I use LinqDataSource and need to make insert not from any data-bound controls like formView (just by pressing button on page).

In SqlDataSource I can set InsertParameters like this

<InsertParameters>
<asp:ControlParameter ControlID="ddlPrice" DefaultValue="0" Name="Price"
PropertyName="SelectedValue" Type="Int16" />
<asp:ControlParameter ControlID="ddlDisc" DefaultValue="0" Name="Discount"
PropertyName="SelectedValue" Type="Int16" />
</InsertParameters>

and then just call Insert().

But in LinqDataSource we don't have method Insert() taking no papameters so I need to create collection with values I want to insert.

View 2 Replies

DataSource Controls :: How To Insert The Grid View Values Into Database

Feb 8, 2010

I have to in sert the gridview values into database, the values can be single or more than one values, so here i have to use the XML to store the data, but my question is?

i have to sent the values as a string, to the database, so how i convert that, and how could i retrieve the values as it is, and stored or display to the another gridview.

im using asp.Net 2005

View 4 Replies

DataSource Controls :: Insert A Range Of Values Into A Database From Front End?

Mar 19, 2010

I want to insert a particular value against a range of dates into my sql server database from the front end using c#.

the table has the column date and worker. so i desire that the user writes the name of the worker and then enters a From and To range into two textboxes so that thorugh a loop function the name of the worker gets written into the table along with the range of chosen dates.

View 18 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved