将数据从一个表复制到另一个表 [英] copying data form one table to another
问题描述
我想知道如何将数据从一个表复制到另一个表.
我想检查一个表中的几行并将这些行复制到新表中.
我还想知道如果一列发生更改,如何将数据复制到同一张表中.
例如,如果我在第1学期的第2学期有一个带有学生数据的学生表,
我想在semester2中复制一些相同的数据.
我是Visual Studio 2010的新手,正在使用asp.net
I would like to know how to copy data from one table to another.
I would like to checked several rows in one table and copy those rows to a new table.
I would also like to know how to copy data to the same table if one column changes.
for example if I have a student table with student data during semester 1 when its semester 2
I would like to copy some of that same data for semester2.
I am new to visual studio 2010 and I am using asp.net
推荐答案
您可以使用查询将一个表的记录复制到另一个表.
以下查询将自动创建destination table
You can use queries for copying records of a table to another table.
Following query will automatically createdestination table
select * into <destination table=""> from <source table=""></source></destination>
如果表已经创建
If the table is already created
insert into <tablename> select * from <table name=""> where [condition].</table></tablename>
谢谢
Ashish
Thanks
Ashish
这是相当基本的数据操作,您应该考虑从这里开始:
http://msdn.microsoft.com/zh-我们/library/system.data.datatable%28v=vs.110%29.aspx [
This is rather basic datamanipulation and you should consider starting here:
http://msdn.microsoft.com/en-us/library/system.data.datatable%28v=vs.110%29.aspx[^]
There are example at the end of that page in the link. So good luck
Partial Class ViewStudents
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each gridviewrow As GridViewRow In GridView1.Rows
Dim checkbox As CheckBox = gridviewrow.Cells(0).FindControl("CheckBox1")
If checkbox.Checked Then
Dim studentId As Integer = GridView1.DataKeys(gridviewrow.RowIndex).Value
Dim FirstName As String = GridView1.DataKeys(gridviewrow.Cells(1).Value.ToString()) 'error! help please with this line
Dim LastName As String
End If
Next
End Sub
这篇关于将数据从一个表复制到另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!