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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql problem

Status
Not open for further replies.

VBmim

Programmer
Jun 25, 2001
361
BE
Hello

I have a problem with default values in my sqlserver database. I have a table Customers with the field 'mailing' (data type 'bit'). This field has a default value 1.
In my vb-program I have a procedure to add a customer with the ado method '.addNew'. When I add a record to this table, the field 'mailing' has value 'NULL'.
Here is my code

objRec2.AddNew
objRec2!CustomerNr = Customer
objRec2!Name = txtName.text
objRec2!Adress = txtadress.Text
objRec2!tel = txttelephone.Text
objRec2!Email = txtemail.Text
objRec2.Update
objRec2.Close

note that the field 'mailing' is not included in the addNew statement...

does anyone know what could be the problem?

tnx in advance

Mim+
 
Back again...

I have an extra problem now... when I try to blink out the option 'allow NULL' and then save the table, I get an error that goes like this:

Table Customer
- Tabel can not be changed.
ODBC-error: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'MAILING', table 'DATABASE.dbo.Tmp_Customer'; column does not allow nulls. INSERT fails.
[Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been terminated.

huh?
 
Hi,

Change the field (mailing) to accept NULLs. Also data type bit only allows 0 or -1. Using 1 as a default value for a bit data type will give you fits.

"Keep Your Code Tight"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top