SELECT a single row with one SqlDataSource, then INSERT one of the fields into another SqlDataSource
What is the C# code I use to do this?
I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.Disco Patrick writes web applications using:Visual Studio 2008ASP.NET 3.5C#SQL Server 2008
What do you mean by "insert one of the fields into another SqlDataSource"? Do you mean you want to make use of the value as a parameter for another datasource control or that you actually want to use another SqlDataSource to insert the value into a table so...
insert multiple values from one table into one column from another table?
Hi,
I'm attempting to create an insert statement that gets the values from multiple columns and insert them into one column from another table, is there a simple solution to do this?Here is something similar to what i'm wanting done, just it's not the correct way to do it, i want value1, value2 and value3 from one table to be combined and put into the value1 column of another table, what am i doing wrong?
INSERT INTO tablename2 (value1 + value2 + value3)SELECT value1FROM tablename1
thanks in advance!
INSERT INTO tablename2 (SELECT val1 + val2 + val3 FROM tabl...
Get records from one table and insert into another one
I make that but I did not work, thanks
SqlCommand cmd2;cmd = new SqlCommand("SELECT CS_ID FROM Tbl_Conselheiros WHERE CS_TIPO IN (5,6,7)", conn);
dr = cmd.ExecuteReader();
while (dr.Read())
{cmd2 = new SqlCommand("SP_PRES_GRAVAR", conn);
cmd2.CommandType = CommandType.StoredProcedure;SqlParameter id = new SqlParameter("@ID_CONSE", SqlDbType.Int, 4);id.Value = Convert.ToInt32(dr[0]);
cmd2.Parameters.Add(id);SqlParameter data2 = new SqlParameter("@DATA", SqlDbType.VarChar, 8);
data2.Value = FormataData();
cmd2.Parameters.Add(data...
One-to-One or Many-to-One?
Hi Friends,I've made huge database for Learning Management Systems which has around 30 - 40 tables.I was checking all the relationships between tables and everything seems fine and well defined. But, it's 4:22 AM here and I'm bit sleepy but I was thinking which of the following relationship is true between the following two tables:Table1: tbl_users (PK username, password, name, surname, email, address1, address2, phNumb)Table2: tbl_testAttempts (PK Id, username, testId, attempt, timeStart, timeEnd)As you see, the Primary key of tbl_users is foreign key in tbl_testAttempts. ...
One to Many to One to One
I have a kinda small problem; if someone could help me that' would be niceTo keep things simplier, allow me to give the following exampleI have two tables one-to-many relationship,table1: itemtable2: itemhistoryitem has many itemhistorybasically i want retrieve all the records in 'item' sorted by 'name', along with ONE "latest" itemhistory" (date). If there aren't any historyhistory for a particular 'item', just allow null values. egcreate table #item(itemid int, name varchar(10))create table #itemhistory(itemhistoryid int, itemid int, date...
can I compare one record from one table to another record in another table?
can I compare one record from one table to another record in another table? I need to test if this condition is met. My scenario is:
i need to check one table for a value and compare it to a list of records. for example,
table 1 columnrecord 1- applesrecord 2- orangesrecord 3- grapes
table 2 col1 col2 col3 col4record 1- Null , Null, Null, grapes
I need to compare table 2 records with a list of records from table 1. the fru...
Selecting data from one table, and counting from another in one query. Help!
Hello,I wrote a news system that has a commenting system. Instead of having to actually keep track of the number of comments inside the news table, I want to get the count directly from the NewsComments table. So my tables:News: id, author, subject, postdate, news, category, commentcountNewsComments:Id, Author, Message, postDate, IP, Browser, NewsId As you can see, when a new comment is posted I have to update the comment count. I don't want to do that. I basically need to select all rows from the news (WHERE Category = 'CATID'), and at the same time COUNT the number of COMM...
select all row one more than one column
I add checkbox control in header template to select all row. if one column have select all propert there is no problem. However, when add second column and add select all another column there occur a problem. When ı select first column select all checkbox, second colum checkbox checked. How can ı solve this problem.
Hi,Following links will help you out ...http://programming.top54u.com/post/ASP-Net-GridView-Checkbox-Select-All-using-C-sharp.aspxhttp://aspnet.4guysfromrolla.com/articles/053106-1.aspxhttp://aspnet.4guy...
CheckBoxList Databinding, Select from One Table, Insert Into another Table
Newbie here!
I've looked all over the place to see if I find some code that can get me started with this project, here it goes guys, as usual, all help is appreciated...
SQL Server, I have 1 table tblServices that shows all of the services we offer, with 3 fields, such as: ID, CategoryCode, CategoryDescription. When loading my web form I want to offer all of these service options showing them the "CategoryDescription" in a checkboxlist option for my users to click on, and then submit the form into a second table. The second table "tblEx...
Stored Procedure
I wish to select all post from Table Category and the first row in Product table.
SQL goes (not working just to show you how im thinking):
SELECT Category.CategoryID, Category.Title, TOP (1) Product.ImagePath, TOP (1) Product.CategoryID
FROM Category INNER JOIN
Product ON Category.CategoryID = Product.CategoryID GROUP BY Category.CategoryID, Category.Title
Thanks for your help!
SELECT Category.CategoryID, Category.Title, Product.ImagePath, Product.CategoryID
FROM Category crossJOIN
(select top 1 * from Product ) PGive a man a fish and you feed him for ...
SQL: mutiple rows one column to multiple columns one rowIn InfoMaker SQL can you take a table with multiple
rows for the same key and take a column from the
rows and create mutiple columns with one
report line with the key(no duplicate keys) on a report? For example
Table books
(key) (book title)
123 misery
123 titanic
123 roots
456 war
456 1984
456 giant
The report I need would look like this
Key title1 title2 title 3
123 misery titanic roots
456 war 1984 giant
Thanks in advance.
--
Kaye Hendry
HealthInsight
email:kaye.hendry@healthinsight.org
...
Selecting from one table inserting into another
hi, i am sure this is very simple, but its just got me stuck! i have a table which i use for inserting products, now its not very exciting to see the cat_id so i wanted to put a dropdown box on there which would show the cat_description from tbl_cat and then put the tbl_cat.cat_id into tbl_products.cat_id
any help would be greatful
JezJeremy HusonSenior Network EngineerCarden Computers - PC Repair Brighton
Hi Jezh,
To display the description of a catelog in a dropdownlist, you will need to have 2 ObjectDataSources.
Please check the following sample for more information:(VB Drop...
selecting from one table, inserting into another
hi there, i have a page where on my button click i need to select address, pcode from tbl_person where person_id = querystring and update or insert those values into tbl_del where order_ID = querystring 2 below is the code i am using, although im stuck on the sql stringSqlConnection objConnAddy = new SqlConnection(sConnectionStringCustInfo);using (objConnAddy)
{
objConnOID.Open();
// insert values into delivery table, second line updates price + VAT
string sqlAddy = "?????";
SqlCommand objCmdAddy = new SqlCommand(sqlAddy, objConnAddy);
objCmd1.ExecuteNonQuery();
i had a loo...
is there an sql statement to insert data to one table and getting the data from another table
Ok I have a table that have general categories with just name and CatNo. Now what I want to know is when I create a client to move all the data in general categories to another table called categories that have the clientid to associate it with the client. I would appreciate for any help
what is your question here??Shravan Addaypally MCP...