tmaususer
asked on
Append Records from one sql table to another
I am new to programming. I have created a form (with help) that loads data from a table I created called yan_con_label. (sql 2000 db) I have a second "empty" table called Archive that is identical to my yan_con_label. All I need to do is create a button that when pressed will append all records from my yan_con_label to my archive table. I do not know how to do this. My code that loads records initally into my grid is as follows:
Imports System.Data.SqlClient
Imports System.Configuration
Imports System
Imports System.IO
Imports System.Net.Mime.MediaTypeN ames
Public Class Form1
Public Global_sqlProdCN As New SqlConnection("Data Source=SERVER04N;Initial Catalog=yamahalabeldb;Inte grated Security=True")
Public Global_ERPsettings As ConnectionStringSettings
Public Global_strERPCN As String
Public Global_sqlERPCN As New SqlConnection
Public Global_dr As SqlDataReader
Public Global_sqlcmd As New SqlCommand
Public Global_strsql As String
Public Global_strProdCN2 As String
Public Global_sqlProdCN2 As New SqlConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim irowcnt As Integer = -1
Global_strsql += " SELECT Part_no, Deliverylocation, po_no, supplier_id, labelcode, qty, duedate, stocklocation, sirlocation "
Global_strsql += " FROM yam_con_label "
Global_strsql += " Order by part_no "
Global_sqlProdCN.Open()
Global_sqlcmd = New SqlCommand(Global_strsql, Global_sqlProdCN)
Global_dr = Global_sqlcmd.ExecuteReade r()
If Global_dr.HasRows Then
While Global_dr.Read
irowcnt += 1
Dim srow() As String = {Global_dr.Item("Part_no") , Global_dr.Item("Deliverylo cation"), Global_dr.Item("po_no"), _
Global_dr.Item("supplier_i d"), Global_dr.Item("labelcode" ), Global_dr.Item("qty"), _
Global_dr.Item("duedate"), Global_dr.Item("stocklocat ion"), Global_dr.Item("sirlocatio n")}
dgYamahadata.Rows.Add(srow )
End While
End If
Global_sqlProdCN.Close()
End Sub
Imports System.Data.SqlClient
Imports System.Configuration
Imports System
Imports System.IO
Imports System.Net.Mime.MediaTypeN
Public Class Form1
Public Global_sqlProdCN As New SqlConnection("Data Source=SERVER04N;Initial Catalog=yamahalabeldb;Inte
Public Global_ERPsettings As ConnectionStringSettings
Public Global_strERPCN As String
Public Global_sqlERPCN As New SqlConnection
Public Global_dr As SqlDataReader
Public Global_sqlcmd As New SqlCommand
Public Global_strsql As String
Public Global_strProdCN2 As String
Public Global_sqlProdCN2 As New SqlConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim irowcnt As Integer = -1
Global_strsql += " SELECT Part_no, Deliverylocation, po_no, supplier_id, labelcode, qty, duedate, stocklocation, sirlocation "
Global_strsql += " FROM yam_con_label "
Global_strsql += " Order by part_no "
Global_sqlProdCN.Open()
Global_sqlcmd = New SqlCommand(Global_strsql, Global_sqlProdCN)
Global_dr = Global_sqlcmd.ExecuteReade
If Global_dr.HasRows Then
While Global_dr.Read
irowcnt += 1
Dim srow() As String = {Global_dr.Item("Part_no")
Global_dr.Item("supplier_i
Global_dr.Item("duedate"),
dgYamahadata.Rows.Add(srow
End While
End If
Global_sqlProdCN.Close()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I figured it out after taking a step back. That is what I needed. Thanks....
ASKER