Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: How identify REQUIRED fields in recordset (adFldIsNullable)?


Message #1 by "Martin Fussek" <fussek@l...> on Tue, 11 Sep 2001 15:04:01
Hello



I got an database with an table tblTelSeznam



| tblTelSeznam

|+++++++++++++

| ID - autonum

| Jmeno - text REQUIRED=true

| Tel - text REQUIRED=false

| Fax - text REQUIRED=false

| email - text REQUIRED=false



The Script for getting values

<%



'---- FieldAttributeEnum Values ----

Const adFldBookmark = &H00000001

Const adFldMayDefer = &H00000002

Const adFldUpdatable = &H00000004

Const adFldUnknownUpdatable = &H00000008

Const adFldFixed = &H00000010

Const adFldIsNullable = &H00000020

Const adFldMayBeNull = &H00000040

Const adFldLong = &H00000080

Const adFldRowID = &H00000100

Const adFldRowVersion = &H00000200

Const adFldCacheDeferred = &H00001000



		

Set objConn= Server.CreateObject("ADODB.Connection")

objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data 

Source=c:\inetpub\wwwroot\vl_data\fpdb\VL_2000_new_vldata.mdb"



Set objCommand = Server.CreateObject("ADODB.Command")

objCommand.ActiveConnection = objConn

objCommand.CommandText = "SELECT ID, Jmeno, Tel, FAX, email FROM 

tblTelSeznam WHERE Jmeno like '%fussek%'"



Set objRecordSet = objCommand.Execute

With Response

Do While Not objRecordSet.EOF

For i = 0 to objRecordSet.Fields.Count - 1

.Write objRecordSet.Fields(i).Attributes AND adFldIsNullable 

.Write " - "

.Write objRecordSet.Fields(i).Name

.Write " - "

.Write objRecordSet.Fields(i).Value

.Write "<BR>"

Next

objRecordSet.MoveNext

Loop

End With

objRecordSet.Close

Set objRecordSet = Nothing

objConn.Close

Set objConn = Nothing

%>



There is an result

0 - ID - 77

32 - Jmeno - Fussek Martin

32 - Tel - +421 (87) 6666 666

32 - FAX - +421 (87) 6666 667

32 - email - fussek@l...



---------------



WHY ALL (??!) fields (except for the ID - it's OK) have attribute REQUIRED 

(eg. 32)



Is something wrong on this line of code?

.Write objRecordSet.Fields(i).Attributes AND adFldIsNullable 



OR How to find out that an field is required??



Message #2 by "Ken Schaefer" <ken@a...> on Wed, 12 Sep 2001 16:58:44 +1000
All the fields have isNullable set - which means that the field isn't

required - it can have a NULL value...isn't that what you want?



adFldIsNullable = &H00000020 = 32 in Decimal = Field can be set to NULL



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- Original Message -----

From: "Martin Fussek" <fussek@l...>

To: "ASP Databases" <asp_databases@p...>

Sent: Tuesday, September 11, 2001 3:04 PM

Subject: [asp_databases] How identify REQUIRED fields in recordset

(adFldIsNullable)?





: Hello

:

: I got an database with an table tblTelSeznam

:

: | tblTelSeznam

: |+++++++++++++

: | ID - autonum

: | Jmeno - text REQUIRED=true

: | Tel - text REQUIRED=false

: | Fax - text REQUIRED=false

: | email - text REQUIRED=false

:

: The Script for getting values

: <%

:

: '---- FieldAttributeEnum Values ----

: Const adFldBookmark = &H00000001

: Const adFldMayDefer = &H00000002

: Const adFldUpdatable = &H00000004

: Const adFldUnknownUpdatable = &H00000008

: Const adFldFixed = &H00000010

: Const adFldIsNullable = &H00000020

: Const adFldMayBeNull = &H00000040

: Const adFldLong = &H00000080

: Const adFldRowID = &H00000100

: Const adFldRowVersion = &H00000200

: Const adFldCacheDeferred = &H00001000

:

:

: Set objConn= Server.CreateObject("ADODB.Connection")

: objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data

: Source=c:\inetpub\wwwroot\vl_data\fpdb\VL_2000_new_vldata.mdb"

:

: Set objCommand = Server.CreateObject("ADODB.Command")

: objCommand.ActiveConnection = objConn

: objCommand.CommandText = "SELECT ID, Jmeno, Tel, FAX, email FROM

: tblTelSeznam WHERE Jmeno like '%fussek%'"

:

: Set objRecordSet = objCommand.Execute

: With Response

: Do While Not objRecordSet.EOF

: For i = 0 to objRecordSet.Fields.Count - 1

: .Write objRecordSet.Fields(i).Attributes AND adFldIsNullable

: .Write " - "

: .Write objRecordSet.Fields(i).Name

: .Write " - "

: .Write objRecordSet.Fields(i).Value

: .Write "<BR>"

: Next

: objRecordSet.MoveNext

: Loop

: End With

: objRecordSet.Close

: Set objRecordSet = Nothing

: objConn.Close

: Set objConn = Nothing

: %>

:

: There is an result

: 0 - ID - 77

: 32 - Jmeno - Fussek Martin

: 32 - Tel - +421 (87) 6666 666

: 32 - FAX - +421 (87) 6666 667

: 32 - email - fussek@l...

:

: ---------------

:

: WHY ALL (??!) fields (except for the ID - it's OK) have attribute REQUIRED

: (eg. 32)

:

: Is something wrong on this line of code?

: .Write objRecordSet.Fields(i).Attributes AND adFldIsNullable

:

: OR How to find out that an field is required??

:

:

:




$subst('Email.Unsub')



Message #3 by "Martin Fussek" <fussek@l...> on Wed, 12 Sep 2001 14:13:20
Hello Ken



IT'S NOT RIGHT Because the field Jmeno has set REQUIRED to true (and it 

cannot have a NULL value).



| Jmeno - text REQUIRED=true



I think that Jmeno must return value 0 (eg. field CANNOT be set to null)



Martin



> All the fields have isNullable set - which means that the field isn't

> required - it can have a NULL value...isn't that what you want?

> 

> adFldIsNullable = &H00000020 = 32 in Decimal = Field can be set to NULL

> 

> Cheers

> Ken

> 

  Return to Index