set warnings

  • Thread starter Thread starter ReidarT
  • Start date Start date
R

ReidarT

I add new records from a table to another table. The aother table has a
unique field. How do I supress the message saying 'duplicate records' like
set warnings = false before the update and set warnings= true after the
update
regards
reidarT
 
You can try using DataAdapter.ContinueUpdateOnError. Here is an excerpt
from MSDN;

If ContinueUpdateOnError is set to true, no exception is thrown when an
error occurs during the update of a row. The update of the row is skipped
and the error information is placed in the RowError property of the row in
error. The DataAdapter continues to update subsequent rows.

If ContinueUpdateOnError is set to false, an exception is thrown when an
error occurs during the update of a row.
 
Reidar,

I analyse your message because I don't understand it.

ReidarT said:
I add new records from a table to another table.
A new record from a table, why not add them one behind the other too both
tables.
The other table has a unique field.
An unique_fiels or a unique key.
How do I supress the message saying 'duplicate records' like
In both cases you should not be able to supress the message, however take
action.
unique is unique

Just my thought,

Cor
 
In Access i set docmd.setwarnings false before the update and
docmd.setwarnings true after the update.

regards
reidarT
 
Provide me with the code you are currently using and I will insert the
statments where needed.
 
Here is the code:
Public Function LeggTilMedlemNyttFirma()

Dim connStringMedlem As String

Dim RsMedlem As ADODB.Recordset

Dim sqlMedlem As String

'***** åpne Connection ToFile

Dim cnnToFile As New ADODB.Connection

cnnToFile.CursorLocation = ADODB.CursorLocationEnum.adUseClient

connStringMedlem = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
H:\HEI2000\Sales.mdb"

cnnToFile.Open(connStringMedlem)

'*** Åpne recordset RsMember

RsMedlem = New ADODB.Recordset

sqlMedlem = "INSERT INTO tblMember (MemberPostcode, MemberCity,
MemberCountry, Firma_nr, " & _

"Memberphone, Selgernavn, Kortinnehaver) " & _

"SELECT MedlemmarTillHEI2000H.[Postal Code], MedlemmarTillHEI2000H.City, " &
_

"MedlemmarTillHEI2000H.Land, 4050 AS CoId, MedlemmarTillHEI2000H.Phone, " &
_

"'Svensk Selger' AS Selger, MedlemmarTillHEI2000H.Namn " & _

"FROM MedlemmarTillHEI2000H LEFT JOIN tblGrunndata ON " & _

"(MedlemmarTillHEI2000H.City = tblGrunndata.GrunndataCity) AND " & _

"(MedlemmarTillHEI2000H.[Company Name] = tblGrunndata.Firmanavn) " & _

"WHERE (((tblGrunndata.GrunndataCity) Is Null) AND ((tblGrunndata.Firmanavn)
Is Null))"

RsMedlem.Open(sqlMedlem, cnnToFile, ADODB.CursorTypeEnum.adOpenKeyset,
ADODB.LockTypeEnum.adLockOptimistic)

End Function
 
I apologize. I wrongly assumed that you were using ADO.NET and not ADODB.

I haven't used ADODB for so long it would take me longer to get back into it
then it would for someone else to answer your post.

Sorry.

--
Gerry O'Brien
Visual Basic .NET MVP


reidarT said:
Here is the code:
Public Function LeggTilMedlemNyttFirma()

Dim connStringMedlem As String

Dim RsMedlem As ADODB.Recordset

Dim sqlMedlem As String

'***** åpne Connection ToFile

Dim cnnToFile As New ADODB.Connection

cnnToFile.CursorLocation = ADODB.CursorLocationEnum.adUseClient

connStringMedlem = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
H:\HEI2000\Sales.mdb"

cnnToFile.Open(connStringMedlem)

'*** Åpne recordset RsMember

RsMedlem = New ADODB.Recordset

sqlMedlem = "INSERT INTO tblMember (MemberPostcode, MemberCity,
MemberCountry, Firma_nr, " & _

"Memberphone, Selgernavn, Kortinnehaver) " & _

"SELECT MedlemmarTillHEI2000H.[Postal Code], MedlemmarTillHEI2000H.City, "
& _

"MedlemmarTillHEI2000H.Land, 4050 AS CoId, MedlemmarTillHEI2000H.Phone, "
& _

"'Svensk Selger' AS Selger, MedlemmarTillHEI2000H.Namn " & _

"FROM MedlemmarTillHEI2000H LEFT JOIN tblGrunndata ON " & _

"(MedlemmarTillHEI2000H.City = tblGrunndata.GrunndataCity) AND " & _

"(MedlemmarTillHEI2000H.[Company Name] = tblGrunndata.Firmanavn) " & _

"WHERE (((tblGrunndata.GrunndataCity) Is Null) AND
((tblGrunndata.Firmanavn) Is Null))"

RsMedlem.Open(sqlMedlem, cnnToFile, ADODB.CursorTypeEnum.adOpenKeyset,
ADODB.LockTypeEnum.adLockOptimistic)

End Function

Gerry O'Brien said:
Provide me with the code you are currently using and I will insert the
statments where needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top