I have the following code:
Dim mytable As New DataTable
Dim mytable2 As New DataTable
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connectionString As String = GetConnectionString("XE_ConnectionString")
Dim providerFactory As DbProviderFactory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client")
Dim Sql = "SELECT RESULTS.RESULT_NUMERIC,REQ_PANELS.RUN_DATE FROM REQ_PANELS, REQUISITIONS, RESULTS, TESTS WHERE REQUISITIONS.ACC_ID = REQ_PANELS.ACC_ID AND REQ_PANELS.RP_ID = RESULTS.RP_ID AND RESULTS.TEST_ID = TESTS.TEST_ID AND (REQUISITIONS.PAT_ID = '3848.1') AND (TESTS.TEST_NAME = 'BUN') ORDER BY REQ_PANELS.RUN_DATE"
Dim connection As DbConnection = providerFactory.CreateConnection
connection.ConnectionString = connectionString
Dim command As DbCommand = providerFactory.CreateCommand
command.Connection = connection
command.CommandText = Sql
command.CommandType = CommandType.Text
connection.Open()
Dim dr As DbDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
mytable.Load(dr)
GridView1.DataSource = mytable
GridView1.DataBind()
connection.Dispose()
command.Dispose()
This gives me a datatable in memory called 'mytable'. The table looks like this:
RESULT_NUMERIC RUN_DATE
10.2 2/4/2009
8.7 3/5/2009
I also have a table in an SQL database called 'Combined_results' with the same column headings (empty rows).
What I need to do is this:
1. Empty the SQL table.
2. Copy the 'mytable' data to the SQL table.
There is no primary key.
I imagine that this is easy to do for the experts but is giving me fits.
Thanks
Dim mytable As New DataTable
Dim mytable2 As New DataTable
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connectionString As String = GetConnectionString("XE_ConnectionString")
Dim providerFactory As DbProviderFactory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client")
Dim Sql = "SELECT RESULTS.RESULT_NUMERIC,REQ_PANELS.RUN_DATE FROM REQ_PANELS, REQUISITIONS, RESULTS, TESTS WHERE REQUISITIONS.ACC_ID = REQ_PANELS.ACC_ID AND REQ_PANELS.RP_ID = RESULTS.RP_ID AND RESULTS.TEST_ID = TESTS.TEST_ID AND (REQUISITIONS.PAT_ID = '3848.1') AND (TESTS.TEST_NAME = 'BUN') ORDER BY REQ_PANELS.RUN_DATE"
Dim connection As DbConnection = providerFactory.CreateConnection
connection.ConnectionString = connectionString
Dim command As DbCommand = providerFactory.CreateCommand
command.Connection = connection
command.CommandText = Sql
command.CommandType = CommandType.Text
connection.Open()
Dim dr As DbDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
mytable.Load(dr)
GridView1.DataSource = mytable
GridView1.DataBind()
connection.Dispose()
command.Dispose()
This gives me a datatable in memory called 'mytable'. The table looks like this:
RESULT_NUMERIC RUN_DATE
10.2 2/4/2009
8.7 3/5/2009
I also have a table in an SQL database called 'Combined_results' with the same column headings (empty rows).
What I need to do is this:
1. Empty the SQL table.
2. Copy the 'mytable' data to the SQL table.
There is no primary key.
I imagine that this is easy to do for the experts but is giving me fits.
Thanks