Copying row to another one in SQL Server from Asp.NET
<p>Assume that there is a table which includes only <code>ID, Name, Company</code> and <code>RealID</code>.</p>

<p>I want to copy one row to another one. For ex:</p>

<pre><code>ID          Name           Company         RealID
</code></pre>

<hr>

<pre><code>1          Marry           Company A        null
2          Jane            Company B        null
3          Watson          Company C        null
4          Marry           Company A         1
5          Watson          Company C         3
</code></pre>

<p>I will do this from asp.net via c# programming language.</p>

<p>My question is:</p>

<p>In c# should I do below?</p>

<pre><code>Class: UserProfile {ID, Name, Company, RealID}
</code></pre>

<p>Code side:</p>

<pre><code>UserProfile userProfile = new UserProfile();
//I have userProfile.ID, userProfile.Name, userProfile.Company and userProfile.RealID
SqlConnection conn = new SqlConnection(sqlConnection);
SqlCommand cmd = new SqlCommand("Select * From UserProfile", conn);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(dr);

//and with a loop, assignment to UserProfile members such as UserProfile.ID = dr[0][i]...
</code></pre>

<p>and after that SQL query will be  </p>

<pre><code>INSERT (Name, Company, RealID) 
VALUES (UserProfile.Name, UserProfile.Company, UserProfile.RealID)
</code></pre>

<p>I search this subject and find this:
<a href="http://stackoverflow.com/questions/10383879/copying-values-from-another-row">Copying values from another row</a>    </p>

<p>but I think my case is different.</p>

<p>Or are there any method to shorten this process?</p>

<p>Shortly:</p>

<p>I want to copy one row to another one in sql from asp.net.</p>

<p>Thanks for help</p>
