Datatable from Ingress to SQL in ASP.NET

cnevas

New member
Joined
Mar 20, 2007
Messages
3
Programming Experience
3-5
I have a database in an IngresII-Server. I need every day to make a copy/update of a specific Table from Ingres into an identical table in a SQL-Server. So, I created a table in SQL, with same name, columns, and field-datatypes as those in Ingres.
In order to update the SQL table I wrote a subroutine to put the Ingres table in a dataset.Then I’d like to update my SQL table with the data stored in the dataset, automatically, without having to pass parameters to a SQL Stored Procedure. The table has 72 columns and 42000 rows. I’d like to use something like the commandbuilder Update (by means of a SqlDataAdapter). I tried that but without success.
Can someone tell me how to do that in an easy way, and, if possible, send me a simple source code example?
I work in VS.NET 2003 , ASPNET 1.1
Thanks in advance,
cnevas
 
Update Database Ingres to SQL

By the way.... My question is similar to thread "Database Update Error" . For better understand please take a look on my source code bellow:
+++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub CmdDbCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdDbCommit.Click
'-----------------------------------------------------------------------------------
'At this point I have already a Table named "bat" in a dataset ds (ds as global variable). This table was got from the Ingres Database,
'by means of other subroutine not here, and I want to use it to update the table "bat" in the SQLServer Database.
'-----------------------------------------------------------------------------------
ds1 = New DataSet

Dim strSQL As String = "Select * From bat"
Dim cnx As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim sda As SqlDataAdapter = New SqlDataAdapter(strSQL, cnx)
sda.Fill(ds1, "bat")
' Here I delete all the rows from "bat" table , wich should be updated
'------------------------------------------------------------------------
For Each targetrow As DataRow In ds1.Tables("bat").Rows
targetrow.Delete()
Next
'------------------------------------------------------------------------
'Here I copy all the rows from "bat" table coming from Ingres in ds dataset, wich will be used for updating the SQL,
'to the "bat" table in SQLServer.
'------------------------------------------------------------------------
Dim row As DataRow
For Each targetrow1 As DataRow In ds.Tables("bat").Rows
row = ds1.Tables("bat").NewRow
row.ItemArray = targetrow1.ItemArray
ds1.Tables("bat").Rows.Add(row)
Next
'-----------------------------------------------------------------------------------
'Here, the table "bat" in ds1 dataset contains all I wanted from Ingres
'----------------------------------------------------------------------
Dim scb As SqlCommandBuilder = New SqlCommandBuilder(sda)
'-----------------------------------------------------------------------
Dim MssgErro As String
Try
sda.Update(ds1, "bat")
lblMsg.Text = IntRows & " database rows updated"
'--------------------------
Catch Exc As SqlException
MssgErro = Exc.Message
lblMsg.Text = MssgErro
Finally
End Try
'------------------------------------------------------------------------
cnx.Close()

End Sub

What am I dooing wrong?
Thanks
cnevas
 
No, I tried to explain in more details. But, I have already find out the error. My table (to be updated) had no PrimaryKey. So, the ComandBuilder Update does not work, no columns are returned by the SelectCommand.
Thanks,
cnevas
 
all tables that are to be updated, should have a primary key. THe only tables that do not need PKs are log tables and other similar tables that just take insert data, occasionally select, but never have updates or deletes run against them
 
Back
Top