cannot contain a null value because the required property for this field is set to true. enter a value in this field.

cannot contain a null value because the required property for this field is set to true. enter a value in this field.

Post by gaffa » Sun, 09 Jan 2005 23:22:03


ello Sir,

The below functionality is used for the database and table creation but
while entering data in the tables from the textboxes if i left any textbox
empty i am arising this error message. please give some piece of help where
to add the property or functionality in the below given functionality

Error Message:
the field 'new_custdetails.salutation' cannot contain a null value because
the required property for this field is set to true. enter a value in this
field.

Dim cat As Catalog = New Catalog

cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source= " & Application.StartupPath & "\databases" & "\" & fname1 &
";" & "Jet OLEDB:Engine Type=5")

cat = Nothing

MsgBox("Database succesfully created")

End If

'creating tables in the database

'

' This code adds a single-field Primary key

'

Dim Cn As ADODB.Connection

Dim Cat2 As ADOX.Catalog

Dim objTable1, objtable2 As ADOX.Table

Cn = New ADODB.Connection

Cat2 = New ADOX.Catalog

objTable1 = New ADOX.Table

objtable2 = New ADOX.Table

'Open the connection

Try

Cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source= " & Application.StartupPath & "\databases" & "\" & fname1 &
";" & "Jet OLEDB:Engine Type=5")

'"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\sample\gaffar.mdb"

Catch ex As Exception

MsgBox(ex.Message)

End Try

'Open the Catalog

Cat2.ActiveConnection = Cn

'Create the table

objTable1.Name = "new_custdetails"

objtable2.Name = "Test_Table2"



'Create and Append a new field to the "Test_Table" Columns Collection



objTable1.Columns.Append("company", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("contact", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("salutation", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("title", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("dept", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("phone", DataTypeEnum.adInteger)

objTable1.Columns.Append("phext1", DataTypeEnum.adInteger)

objTable1.Columns.Append("fax", DataTypeEnum.adInteger)

objTable1.Columns.Append("mobile", DataTypeEnum.adInteger)

objTable1.Columns.Append("altphone", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("phext2", DataTypeEnum.adInteger)

objTable1.Columns.Append("status", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("dob", DataTypeEnum.adDate)

objTable1.Columns.Append("address1", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("address2", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("city", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("state", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("zip", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("country", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("reffered", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("website", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("email", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("lastresult", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("contact2", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("title2", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("phone2", DataTypeEnum.adInteger)

objTable1.Columns.Append("phext", DataTypeEnum.adInteger)

objTable1.Columns.Append("create_date", DataTypeEnum.adDate)

objTable1.Columns.Append("pub_pri", DataTypeEnum.adVarWChar)

objTable1.Columns.Append("rec_creator", DataTypeEnum.adVarWC