Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert wit empty fields 1

Status
Not open for further replies.

bakira4

Programmer
May 19, 2008
8
0
0
FR
Hi everyone,
I try to make an insert query but some of my fields wich I want to insert must be empty and I receive an error like when they are empty:

"[Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine Interface]Syntax Error: Insert into CONTACTS(typeTiers,CodeTiers,sContact_Interloc,sContact_Url,sContatc_Tel,sContact_fax)
values('',0,<<???>>,,,)"

How can I do to avoid this error?

Thanks,
Bakira
 
information:

This query should permit me to transfer data from database access to BTR.

Thanks,
Bakira
 
You can't pass nothing. You have to pass some value. You might try "null" or an empty string. Something like:
"Insert into CONTACTS (typeTiers,CodeTiers,sContact_Interloc,sContact_Url,sContatc_Tel,sContact_fax)
values ('',0,null,null,null,null)"
or
"Insert into CONTACTS (typeTiers,CodeTiers,sContact_Interloc,sContact_Url,sContatc_Tel,sContact_fax)
values ('',0,'','','','')"

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
Thanks mirtheil,
you're, as already, give me a solution :)

However, I still have a problem...

I've 2 databases, on access database and a pervasive database
I must do a research of duplicate between this 2 databases.
I trail databases and if a duplicate is find, the row is logged else the rows is saved in the pervasive database.

The problem is that I received a bTrieve Error 5 (duplicate keys) before my test; when I placed my recordset at the top with property MoveFirst (VB6 programation)?

can you give me some help please?

bakira
 
You should never see an error 5 on a MoveFirst. Can you post your code that returns the status 5?

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
This is my code :


Private Function VerifierExistence(ByRef pinout_objRecordSet As Object, ByVal pin_strNom As String, ByVal pin_strId As String, ByVal pin_strCode As String, ByVal pin_strN As String) As Integer


Dim x As Integer
'déclaration variable
Dim intResultat As Integer 'retour du resultat (0,1,2)
Dim blnTrouve As Boolean 'si trouvé

'valeur par defaut 0, non trouvé
intResultat = 0

'positionnement au debut
pinout_objRecordSet.MoveFirst

'valeur par defaut, non trouvé
blnTrouve = False

'tant qu'one st pas a la fin ou qu'on a pas trouvé la ligne
While pinout_objRecordSet.EOF = False And blnTrouve = False

'si le doublon nom
If StrComp(UCase(pinout_objRecordSet.Fields(pin_strN).Value), UCase(pin_strNom)) = 1 Then
'ligne trouvé
blnTrouve = True
'retour 1
intResultat = 1
Else
'si doublon ID
If pinout_objRecordSet.Fields(pin_strCode).Value = pin_strId Then
'ligne trouvé
blnTrouve = True
'retour 2
intResultat = 2
End If
End If
'chnagement de ligne d'enregistrement
pinout_objRecordSet.MoveNext
Wend

'retourne la valeur
VerifierExistenceDansBase = intResultat

End Function


The BTrieve error 5 is on the ligne "pinout_objRecordSet.MoveFirst"
and when I passed this ligne in comment, the error is on the "pinout_objRecordSet.MoveNext" ligne.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top