Problems with textbox-ado-mysql

xblanch
12-18-2006, 10:22 AM
Hi everyone!

I have a problem updating a table via ado.recordset.
The trouble begins in a routine that take values by TEXTBOX CONTROL to ADO.RECORDSET. The field I want to write is Primary Key and cannot be null. If the textbox = "" the ADO.Recordset catch this value and insert a blank record in the mysql table. How can I resolve this issue??

Thanks in advance

wayneph
12-18-2006, 10:27 AM
test the data in your text box before you write it to the recordset...

xblanch
12-19-2006, 01:20 AM
Hi again!!

How can I test the data? In MySQL a empty textbox or "" is different value than NULL. Can I pass via code a null value to a Recordset?

Thanks

xblanch
12-19-2006, 03:47 AM
I put an example:


ON ERROR GOTO CONTROL_ERR

RS.ADDNEW
RS.FIELDS("TX_ID") = TXT_ID -> TXT_ID=""
RS.UPDATE

EXIT SUB

CONTROL_ERR

TX_ID is Primary Key and cannot be null.
In mysql this routine insert a blank record. I want to know if is posible that the Mysql Engine returns an error telling Primary Key violation.

PianoMan
12-19-2006, 07:10 AM
As wayneph suggested, test to make sure there is something in the textbox before you attempt to write it to the recordset:If TXT_ID = "" Then
'Dont save the record
msgbox "The textbox cannot be blank"
Else
'Save the record
End if

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum