Importing MS Access to MS SQL Server












0














Currently trying to update an SQL Server database from an Access db, it works importing new records but fails on when I reimport the file and there is a duplicate - in looking for it to insert the row if it's not there (working), but skip if it already exists. The first column has the primary key set.



Dim table As DataTable = New DataTable
Dim accConnection As New OleDb.OleDbConnection(
"Provider=Microsoft.JET.OLEDB.4.0; Data Source='C:Tester.mdb';User Id=admin; Password=;")
Dim sqlConnection As New SqlClient.SqlConnection(
"Data Source=10.75.24.94;Initial Catalog=CTData;User ID=sql;Password=")
Try
'Import the Access data
accConnection.Open()
Dim accDataAdapter = New OleDb.OleDbDataAdapter(
"SELECT * FROM Import_test", accConnection)
accDataAdapter.Fill(table)
accConnection.Close()
'Export to MS SQL
For Each row As DataRow In table.Rows
row.SetAdded()
Next
sqlConnection.Open()
Dim sqlDataAdapter As New SqlClient.SqlDataAdapter(
"SELECT * FROM Import_test", sqlConnection)
Dim sqlCommandBuilder As New SqlClient.SqlCommandBuilder(sqlDataAdapter)
sqlDataAdapter.InsertCommand = sqlCommandBuilder.GetInsertCommand()
sqlDataAdapter.UpdateCommand = sqlCommandBuilder.GetUpdateCommand()
sqlDataAdapter.DeleteCommand = sqlCommandBuilder.GetDeleteCommand()
sqlDataAdapter.Update(table)
sqlConnection.Close()
Catch ex As Exception
If accConnection.State = ConnectionState.Open Then
accConnection.Close()
End If
If sqlConnection.State = ConnectionState.Open Then
sqlConnection.Close()
End If
MessageBox.Show("Import failed with error: " &
Environment.NewLine & Environment.NewLine &
ex.ToString)
End Try


The error I'm presented with is:




Violation of Primary key. Cannot insert duplicate key in object.











share|improve this question




















  • 1




    You are not checking for duplicates there. Can't you just delete all the records on SQL Server table, before copying again from Access database?
    – Pedro Gaspar
    Nov 23 '18 at 14:24






  • 1




    If you've imported the data, why are you trying to import it again? Is this part of a test cycle? If so, you'll want to likely TRUNCATE your tables first.
    – Larnu
    Nov 23 '18 at 14:59










  • Load into a temp table, then use insert where not exists, update and delete where not exists to update the SQL server table.
    – Ben
    Nov 23 '18 at 14:59










  • You might consider looking at t-sql merge statement. I have a simple example here
    – Karen Payne
    Nov 23 '18 at 19:59










  • @KarenPayne nice link to your example but I would like to copy the code. Why, oh why, would you post your code as an image???
    – Mary
    Nov 23 '18 at 23:06
















0














Currently trying to update an SQL Server database from an Access db, it works importing new records but fails on when I reimport the file and there is a duplicate - in looking for it to insert the row if it's not there (working), but skip if it already exists. The first column has the primary key set.



Dim table As DataTable = New DataTable
Dim accConnection As New OleDb.OleDbConnection(
"Provider=Microsoft.JET.OLEDB.4.0; Data Source='C:Tester.mdb';User Id=admin; Password=;")
Dim sqlConnection As New SqlClient.SqlConnection(
"Data Source=10.75.24.94;Initial Catalog=CTData;User ID=sql;Password=")
Try
'Import the Access data
accConnection.Open()
Dim accDataAdapter = New OleDb.OleDbDataAdapter(
"SELECT * FROM Import_test", accConnection)
accDataAdapter.Fill(table)
accConnection.Close()
'Export to MS SQL
For Each row As DataRow In table.Rows
row.SetAdded()
Next
sqlConnection.Open()
Dim sqlDataAdapter As New SqlClient.SqlDataAdapter(
"SELECT * FROM Import_test", sqlConnection)
Dim sqlCommandBuilder As New SqlClient.SqlCommandBuilder(sqlDataAdapter)
sqlDataAdapter.InsertCommand = sqlCommandBuilder.GetInsertCommand()
sqlDataAdapter.UpdateCommand = sqlCommandBuilder.GetUpdateCommand()
sqlDataAdapter.DeleteCommand = sqlCommandBuilder.GetDeleteCommand()
sqlDataAdapter.Update(table)
sqlConnection.Close()
Catch ex As Exception
If accConnection.State = ConnectionState.Open Then
accConnection.Close()
End If
If sqlConnection.State = ConnectionState.Open Then
sqlConnection.Close()
End If
MessageBox.Show("Import failed with error: " &
Environment.NewLine & Environment.NewLine &
ex.ToString)
End Try


The error I'm presented with is:




Violation of Primary key. Cannot insert duplicate key in object.











share|improve this question




















  • 1




    You are not checking for duplicates there. Can't you just delete all the records on SQL Server table, before copying again from Access database?
    – Pedro Gaspar
    Nov 23 '18 at 14:24






  • 1




    If you've imported the data, why are you trying to import it again? Is this part of a test cycle? If so, you'll want to likely TRUNCATE your tables first.
    – Larnu
    Nov 23 '18 at 14:59










  • Load into a temp table, then use insert where not exists, update and delete where not exists to update the SQL server table.
    – Ben
    Nov 23 '18 at 14:59










  • You might consider looking at t-sql merge statement. I have a simple example here
    – Karen Payne
    Nov 23 '18 at 19:59










  • @KarenPayne nice link to your example but I would like to copy the code. Why, oh why, would you post your code as an image???
    – Mary
    Nov 23 '18 at 23:06














0












0








0







Currently trying to update an SQL Server database from an Access db, it works importing new records but fails on when I reimport the file and there is a duplicate - in looking for it to insert the row if it's not there (working), but skip if it already exists. The first column has the primary key set.



Dim table As DataTable = New DataTable
Dim accConnection As New OleDb.OleDbConnection(
"Provider=Microsoft.JET.OLEDB.4.0; Data Source='C:Tester.mdb';User Id=admin; Password=;")
Dim sqlConnection As New SqlClient.SqlConnection(
"Data Source=10.75.24.94;Initial Catalog=CTData;User ID=sql;Password=")
Try
'Import the Access data
accConnection.Open()
Dim accDataAdapter = New OleDb.OleDbDataAdapter(
"SELECT * FROM Import_test", accConnection)
accDataAdapter.Fill(table)
accConnection.Close()
'Export to MS SQL
For Each row As DataRow In table.Rows
row.SetAdded()
Next
sqlConnection.Open()
Dim sqlDataAdapter As New SqlClient.SqlDataAdapter(
"SELECT * FROM Import_test", sqlConnection)
Dim sqlCommandBuilder As New SqlClient.SqlCommandBuilder(sqlDataAdapter)
sqlDataAdapter.InsertCommand = sqlCommandBuilder.GetInsertCommand()
sqlDataAdapter.UpdateCommand = sqlCommandBuilder.GetUpdateCommand()
sqlDataAdapter.DeleteCommand = sqlCommandBuilder.GetDeleteCommand()
sqlDataAdapter.Update(table)
sqlConnection.Close()
Catch ex As Exception
If accConnection.State = ConnectionState.Open Then
accConnection.Close()
End If
If sqlConnection.State = ConnectionState.Open Then
sqlConnection.Close()
End If
MessageBox.Show("Import failed with error: " &
Environment.NewLine & Environment.NewLine &
ex.ToString)
End Try


The error I'm presented with is:




Violation of Primary key. Cannot insert duplicate key in object.











share|improve this question















Currently trying to update an SQL Server database from an Access db, it works importing new records but fails on when I reimport the file and there is a duplicate - in looking for it to insert the row if it's not there (working), but skip if it already exists. The first column has the primary key set.



Dim table As DataTable = New DataTable
Dim accConnection As New OleDb.OleDbConnection(
"Provider=Microsoft.JET.OLEDB.4.0; Data Source='C:Tester.mdb';User Id=admin; Password=;")
Dim sqlConnection As New SqlClient.SqlConnection(
"Data Source=10.75.24.94;Initial Catalog=CTData;User ID=sql;Password=")
Try
'Import the Access data
accConnection.Open()
Dim accDataAdapter = New OleDb.OleDbDataAdapter(
"SELECT * FROM Import_test", accConnection)
accDataAdapter.Fill(table)
accConnection.Close()
'Export to MS SQL
For Each row As DataRow In table.Rows
row.SetAdded()
Next
sqlConnection.Open()
Dim sqlDataAdapter As New SqlClient.SqlDataAdapter(
"SELECT * FROM Import_test", sqlConnection)
Dim sqlCommandBuilder As New SqlClient.SqlCommandBuilder(sqlDataAdapter)
sqlDataAdapter.InsertCommand = sqlCommandBuilder.GetInsertCommand()
sqlDataAdapter.UpdateCommand = sqlCommandBuilder.GetUpdateCommand()
sqlDataAdapter.DeleteCommand = sqlCommandBuilder.GetDeleteCommand()
sqlDataAdapter.Update(table)
sqlConnection.Close()
Catch ex As Exception
If accConnection.State = ConnectionState.Open Then
accConnection.Close()
End If
If sqlConnection.State = ConnectionState.Open Then
sqlConnection.Close()
End If
MessageBox.Show("Import failed with error: " &
Environment.NewLine & Environment.NewLine &
ex.ToString)
End Try


The error I'm presented with is:




Violation of Primary key. Cannot insert duplicate key in object.








sql-server vb.net ms-access jet






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 14:55









Pedro Gaspar

541321




541321










asked Nov 23 '18 at 13:33









Peter James

437




437








  • 1




    You are not checking for duplicates there. Can't you just delete all the records on SQL Server table, before copying again from Access database?
    – Pedro Gaspar
    Nov 23 '18 at 14:24






  • 1




    If you've imported the data, why are you trying to import it again? Is this part of a test cycle? If so, you'll want to likely TRUNCATE your tables first.
    – Larnu
    Nov 23 '18 at 14:59










  • Load into a temp table, then use insert where not exists, update and delete where not exists to update the SQL server table.
    – Ben
    Nov 23 '18 at 14:59










  • You might consider looking at t-sql merge statement. I have a simple example here
    – Karen Payne
    Nov 23 '18 at 19:59










  • @KarenPayne nice link to your example but I would like to copy the code. Why, oh why, would you post your code as an image???
    – Mary
    Nov 23 '18 at 23:06














  • 1




    You are not checking for duplicates there. Can't you just delete all the records on SQL Server table, before copying again from Access database?
    – Pedro Gaspar
    Nov 23 '18 at 14:24






  • 1




    If you've imported the data, why are you trying to import it again? Is this part of a test cycle? If so, you'll want to likely TRUNCATE your tables first.
    – Larnu
    Nov 23 '18 at 14:59










  • Load into a temp table, then use insert where not exists, update and delete where not exists to update the SQL server table.
    – Ben
    Nov 23 '18 at 14:59










  • You might consider looking at t-sql merge statement. I have a simple example here
    – Karen Payne
    Nov 23 '18 at 19:59










  • @KarenPayne nice link to your example but I would like to copy the code. Why, oh why, would you post your code as an image???
    – Mary
    Nov 23 '18 at 23:06








1




1




You are not checking for duplicates there. Can't you just delete all the records on SQL Server table, before copying again from Access database?
– Pedro Gaspar
Nov 23 '18 at 14:24




You are not checking for duplicates there. Can't you just delete all the records on SQL Server table, before copying again from Access database?
– Pedro Gaspar
Nov 23 '18 at 14:24




1




1




If you've imported the data, why are you trying to import it again? Is this part of a test cycle? If so, you'll want to likely TRUNCATE your tables first.
– Larnu
Nov 23 '18 at 14:59




If you've imported the data, why are you trying to import it again? Is this part of a test cycle? If so, you'll want to likely TRUNCATE your tables first.
– Larnu
Nov 23 '18 at 14:59












Load into a temp table, then use insert where not exists, update and delete where not exists to update the SQL server table.
– Ben
Nov 23 '18 at 14:59




Load into a temp table, then use insert where not exists, update and delete where not exists to update the SQL server table.
– Ben
Nov 23 '18 at 14:59












You might consider looking at t-sql merge statement. I have a simple example here
– Karen Payne
Nov 23 '18 at 19:59




You might consider looking at t-sql merge statement. I have a simple example here
– Karen Payne
Nov 23 '18 at 19:59












@KarenPayne nice link to your example but I would like to copy the code. Why, oh why, would you post your code as an image???
– Mary
Nov 23 '18 at 23:06




@KarenPayne nice link to your example but I would like to copy the code. Why, oh why, would you post your code as an image???
– Mary
Nov 23 '18 at 23:06












1 Answer
1






active

oldest

votes


















0














I think you can remove VB from the equation (I like to make things as simple as possible, without over-simplifying it). You have several options available.



INSERT INTO Table
SELECT * FROM #Table xx
WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)


Or . . .



DELETE FROM Table
WHERE (ID NOT IN (SELECT MAX(ID) AS Expr1
FROM Table
AS Table_1 GROUP BY NAME,ADDRESS,CITY,STATE,ZIP,PHONE,ETC.))


There are a lot of other ways to handle this as well. Is you need to incorporate VB, you can do something like this.



Dim cmd As New OleDbCommand
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:your_pathDB.accdb")

Dim queryResult As Integer
Dim sqlQRY As String = "SELECT COUNT(*) AS FROM ESRRegister WHERE ID = '" & IDtxt.Text & "'"
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Text
If queryResult > 0 Then
cmd.CommandText = "insert into ESRRegister (Dt,ID)VALUES ('" & Dttxt.Text & "' , '" & IDtxt.Text & "')"
queryResult = cmd.ExecuteScalar()
MsgBox("Added Successfuly")
Else

MessageBox.Show("Already Exists!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If





share|improve this answer





















  • Im guessing i can remove the sqlCommandBuilder, with its update, insert and delete from the code and change the sqlDataAdapter select command and replace it with the first suggestion of "INSERT INTO Table SELECT * FROM #Table xx WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)" would that work with some changes? have 4 columns in the table that need to be different before it inserts that perticular row, they are PRODUCT_ID, DATE_TIME, User_Name and ComponentName. If those 4 are already in the table then they need to be ignored.
    – Peter James
    Nov 26 '18 at 8:11











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447692%2fimporting-ms-access-to-ms-sql-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I think you can remove VB from the equation (I like to make things as simple as possible, without over-simplifying it). You have several options available.



INSERT INTO Table
SELECT * FROM #Table xx
WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)


Or . . .



DELETE FROM Table
WHERE (ID NOT IN (SELECT MAX(ID) AS Expr1
FROM Table
AS Table_1 GROUP BY NAME,ADDRESS,CITY,STATE,ZIP,PHONE,ETC.))


There are a lot of other ways to handle this as well. Is you need to incorporate VB, you can do something like this.



Dim cmd As New OleDbCommand
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:your_pathDB.accdb")

Dim queryResult As Integer
Dim sqlQRY As String = "SELECT COUNT(*) AS FROM ESRRegister WHERE ID = '" & IDtxt.Text & "'"
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Text
If queryResult > 0 Then
cmd.CommandText = "insert into ESRRegister (Dt,ID)VALUES ('" & Dttxt.Text & "' , '" & IDtxt.Text & "')"
queryResult = cmd.ExecuteScalar()
MsgBox("Added Successfuly")
Else

MessageBox.Show("Already Exists!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If





share|improve this answer





















  • Im guessing i can remove the sqlCommandBuilder, with its update, insert and delete from the code and change the sqlDataAdapter select command and replace it with the first suggestion of "INSERT INTO Table SELECT * FROM #Table xx WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)" would that work with some changes? have 4 columns in the table that need to be different before it inserts that perticular row, they are PRODUCT_ID, DATE_TIME, User_Name and ComponentName. If those 4 are already in the table then they need to be ignored.
    – Peter James
    Nov 26 '18 at 8:11
















0














I think you can remove VB from the equation (I like to make things as simple as possible, without over-simplifying it). You have several options available.



INSERT INTO Table
SELECT * FROM #Table xx
WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)


Or . . .



DELETE FROM Table
WHERE (ID NOT IN (SELECT MAX(ID) AS Expr1
FROM Table
AS Table_1 GROUP BY NAME,ADDRESS,CITY,STATE,ZIP,PHONE,ETC.))


There are a lot of other ways to handle this as well. Is you need to incorporate VB, you can do something like this.



Dim cmd As New OleDbCommand
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:your_pathDB.accdb")

Dim queryResult As Integer
Dim sqlQRY As String = "SELECT COUNT(*) AS FROM ESRRegister WHERE ID = '" & IDtxt.Text & "'"
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Text
If queryResult > 0 Then
cmd.CommandText = "insert into ESRRegister (Dt,ID)VALUES ('" & Dttxt.Text & "' , '" & IDtxt.Text & "')"
queryResult = cmd.ExecuteScalar()
MsgBox("Added Successfuly")
Else

MessageBox.Show("Already Exists!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If





share|improve this answer





















  • Im guessing i can remove the sqlCommandBuilder, with its update, insert and delete from the code and change the sqlDataAdapter select command and replace it with the first suggestion of "INSERT INTO Table SELECT * FROM #Table xx WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)" would that work with some changes? have 4 columns in the table that need to be different before it inserts that perticular row, they are PRODUCT_ID, DATE_TIME, User_Name and ComponentName. If those 4 are already in the table then they need to be ignored.
    – Peter James
    Nov 26 '18 at 8:11














0












0








0






I think you can remove VB from the equation (I like to make things as simple as possible, without over-simplifying it). You have several options available.



INSERT INTO Table
SELECT * FROM #Table xx
WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)


Or . . .



DELETE FROM Table
WHERE (ID NOT IN (SELECT MAX(ID) AS Expr1
FROM Table
AS Table_1 GROUP BY NAME,ADDRESS,CITY,STATE,ZIP,PHONE,ETC.))


There are a lot of other ways to handle this as well. Is you need to incorporate VB, you can do something like this.



Dim cmd As New OleDbCommand
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:your_pathDB.accdb")

Dim queryResult As Integer
Dim sqlQRY As String = "SELECT COUNT(*) AS FROM ESRRegister WHERE ID = '" & IDtxt.Text & "'"
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Text
If queryResult > 0 Then
cmd.CommandText = "insert into ESRRegister (Dt,ID)VALUES ('" & Dttxt.Text & "' , '" & IDtxt.Text & "')"
queryResult = cmd.ExecuteScalar()
MsgBox("Added Successfuly")
Else

MessageBox.Show("Already Exists!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If





share|improve this answer












I think you can remove VB from the equation (I like to make things as simple as possible, without over-simplifying it). You have several options available.



INSERT INTO Table
SELECT * FROM #Table xx
WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)


Or . . .



DELETE FROM Table
WHERE (ID NOT IN (SELECT MAX(ID) AS Expr1
FROM Table
AS Table_1 GROUP BY NAME,ADDRESS,CITY,STATE,ZIP,PHONE,ETC.))


There are a lot of other ways to handle this as well. Is you need to incorporate VB, you can do something like this.



Dim cmd As New OleDbCommand
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:your_pathDB.accdb")

Dim queryResult As Integer
Dim sqlQRY As String = "SELECT COUNT(*) AS FROM ESRRegister WHERE ID = '" & IDtxt.Text & "'"
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Text
If queryResult > 0 Then
cmd.CommandText = "insert into ESRRegister (Dt,ID)VALUES ('" & Dttxt.Text & "' , '" & IDtxt.Text & "')"
queryResult = cmd.ExecuteScalar()
MsgBox("Added Successfuly")
Else

MessageBox.Show("Already Exists!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 15:31









ryguy72

4,0011619




4,0011619












  • Im guessing i can remove the sqlCommandBuilder, with its update, insert and delete from the code and change the sqlDataAdapter select command and replace it with the first suggestion of "INSERT INTO Table SELECT * FROM #Table xx WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)" would that work with some changes? have 4 columns in the table that need to be different before it inserts that perticular row, they are PRODUCT_ID, DATE_TIME, User_Name and ComponentName. If those 4 are already in the table then they need to be ignored.
    – Peter James
    Nov 26 '18 at 8:11


















  • Im guessing i can remove the sqlCommandBuilder, with its update, insert and delete from the code and change the sqlDataAdapter select command and replace it with the first suggestion of "INSERT INTO Table SELECT * FROM #Table xx WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)" would that work with some changes? have 4 columns in the table that need to be different before it inserts that perticular row, they are PRODUCT_ID, DATE_TIME, User_Name and ComponentName. If those 4 are already in the table then they need to be ignored.
    – Peter James
    Nov 26 '18 at 8:11
















Im guessing i can remove the sqlCommandBuilder, with its update, insert and delete from the code and change the sqlDataAdapter select command and replace it with the first suggestion of "INSERT INTO Table SELECT * FROM #Table xx WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)" would that work with some changes? have 4 columns in the table that need to be different before it inserts that perticular row, they are PRODUCT_ID, DATE_TIME, User_Name and ComponentName. If those 4 are already in the table then they need to be ignored.
– Peter James
Nov 26 '18 at 8:11




Im guessing i can remove the sqlCommandBuilder, with its update, insert and delete from the code and change the sqlDataAdapter select command and replace it with the first suggestion of "INSERT INTO Table SELECT * FROM #Table xx WHERE NOT EXISTS (SELECT 1 FROM Table rs WHERE rs.id = xx.id)" would that work with some changes? have 4 columns in the table that need to be different before it inserts that perticular row, they are PRODUCT_ID, DATE_TIME, User_Name and ComponentName. If those 4 are already in the table then they need to be ignored.
– Peter James
Nov 26 '18 at 8:11


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447692%2fimporting-ms-access-to-ms-sql-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks