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

G

gaffar

Hello 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.adVarWChar)

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

'Create and Append a new key. Note that we are merely passing

'the "PimaryKey_Field" column as the source of the primary key. This

'new Key will be Appended to the Keys Collection of "Test_Table"

''objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyPrimary, "company")
', "new_custdetails")

'objTable1.Keys.Append("PrimaryKey", KeyTypeEnum.adKeyUnique, "contact") ',
"new_custdetails")


'objTable1.Keys.Append("PrimaryKey3", KeyTypeEnum.adKeyPrimary, "dept",
"new_custdetails")

'Append the newly created table to the Tables Collection

Try

Cat2.Tables.Append(objTable1)

Catch ex As Exception

MsgBox(ex.message)

End Try

Cat2.Tables.Append(objtable2)
 

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

Top