Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am needing to get a value out of LoadInfoDataSet.Load_Info_TableDataTable("COST_PER_MILE") and put that value into a textbox of my Fuel form then write/save that value to: Fuel.Fuel_TableDataTable("COST_PER_MILE") and leaving the data in LoadInfoDataSet.Load_Info_TableDataTable("COST_PER_MILE"). This is not a move, it is a copy.

I know an inner join is required to read in the data but not sure how to do this. I am using MSSQL databases.

I am not very good at syntaxing table joining properly then re-writing that data to a different table. I'm sure the below code will bomb at first try since I am not sure how to do this. Can someone point me into the right direction please?

So in summary:
1. I need to create a left outer join to dbo.Load_Info_Table since my fuel form is writing to dbo.Fuel_Table by "default."
2. I need to read in the value of "Load_Info_Table.COST_PER_MILE" and populate that value into my fuel form.
3. When the fuel form is saved it needs to write that same value into "Fuel_Table.COST_PER_MILE".
4. Leaving column "Load_Info_Table.COST_PER_MILE information unchanged and undisturbed.

What I have tried:

My code I tried obviously generated much confusion so have removed it in the hopes that a new solution can be submitted.
Posted
Updated 9-Sep-16 3:57am
v10
Comments
Maciej Los 7-Sep-16 10:57am    
Could you be more specific and provide some example to show exactly what you want to achieve?

Assuming you have two tables A and B and both are having columns x and y.

Now you want to insert data of table A into table B (value of x column of A table into x column of B table and so forth)

The query would be -
SQL
insert into B (x,y) select x,y form A


You can write the query in above format. The above query is a single query do not mistake it for two different queries.
 
Share this answer
 
Comments
K3JAE 9-Sep-16 0:20am    
This appears to be a solution to be ran under MSSQL and will not accomplish my end goal. This SQL inserts new rows into the table. I am not wanting to insert new rows but placing data from TABLE_A into a pre-existing, and currently blank column, within an existing row of TABLE_B.
I need to match PETS_LOAD_NUMBER of both Tables so the proper data of TABLE_A.COST_PER_MILE is inserted to the proper record of TABLE_B.COST_PER_MILE.
I am not sure if i understood problem statement correctly.
Assuming that you want to "copy/update SQL Table from one table to another using C# DataAdapter"

please refer copy/update SQL Table from one SqlConnection to another using C# DataAdapter[^]
 
Share this answer
 
Comments
K3JAE 9-Sep-16 9:48am    
I am not using C#. I am using VB.NET. I want to incorporate this into my program where the user does not see this happen.
manu_dhobale 9-Sep-16 11:50am    
Converting C# to Vb should not be a big deal, there many online site/tools to convert code from C# to Vb
K3JAE 9-Sep-16 17:39pm    
Since I am a poor programmer - just learning - this is not real helpful. I am not even sure how to start this process let alone do it in C# then converting it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900