Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Everyone try this code...


Message #1 by "Alex Barnard" <dumbardos@b...> on Mon, 11 Mar 2002 13:35:08
Anyone reading this please try the code below. It will only take 5 mins of 

your time but it is very important. 



All you have to do is copy and paste the code (between ========) into a 

blank text file anywhere on you Webserver (e.g. c:\inetpub\wwwroot) and 

call it "nulltest.asp" 



Open a browser and load the test ASP file "nulltest.asp"

e.g. http://127.0.0.1/nulltest.asp



The code will create the following database "C:\adoNullTest.mdb" delete 

this file once you have finished testing.



I get the following result displayed in my browser window.......



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

Field :NonNullableField

Attrib:234

Nullable :True

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

Field :NullableField

Attrib:234

Nullable :True

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



Please paste your results as a reply to this thread. The more of you who 

reply, the better our understanding of ADO and ODBC database connectivity.



Many thanks for your time. And for the geniuses out there, tell us all why 

these results are wrong....



THE CODE (copy between =====)

====================================================

<%

Option Explicit

const DB_PATH="C:\adoNullTest.mdb"

Const adOpenStatic = 3

Const adLockReadOnly = 1

Const adFldIsNullable = &H00000020



Dim conn,dbString,rs,FSYS,newdb,fld



'CHECK EXISTING EXAMPLE DB EXISTS

set FSYS=createobject("Scripting.FilesystemObject")

if FSYS.fileexists(DB_PATH) then

	'DELETE TEST DB

	FSYS.deletefile DB_PATH

end if	



'CREATE TEST DATABASE

dbString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&DB_PATH&";"

Set newdb = Server.CreateObject("ADOX.Catalog") 

newdb.create dbString

set newdb=nothing



'THE REAL STUFF STARTS HERE......................



'OPEN DB CONNECTION OBJECT

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

conn.Open dbString

'CREATE TABLE+FIELDS 1)NONNULLABLE 2)NULLABLE

conn.Execute "CREATE TABLE AdoNullableTest " & _

                "(NonNullableField TEXT NOT NULL, NullableField TEXT)"



' Open a recordset on the new table - I use a Query rather then a table 

'(adCmdTable) as I need to use SQL commands.

set rs = Server.CreateObject("ADODB.Recordset") 

rs.Open "SELECT * FROM AdoNullableTest",conn,adOpenStatic,adLockReadOnly

'LOOP FOR EACH FIELD IN DB

for each fld in rs.Fields

	'SHOW NAME-VALUE-NULLABILITY

	response.write "<b>Field</b> :" & fld.Name & "<BR>"

	response.write "<b>Attrib</b>:" & fld.Attributes & "<BR>"

	response.write "<b>Nullable</b> :"&((fld.Attributes and _

    adFldIsNullable)=adFldIsNullable)&"<hr>"

Next

'CLEAR UP

rs.Close

conn.close

set fSYS=nothing

set rs=nothing

set conn=nothing

%>

========================================================================

Message #2 by "Alex Barnard" <dumbardos@b...> on Mon, 11 Mar 2002 18:37:48
Sorry guys I have just confused you all there I said above 



>But I get a 

>FALSE and Attrib:234 for both fields - incorrect.



When I should of said.



But I get a 

"TRUE" and Attrib:234 for both fields - incorrect.











Message #3 by "Alex Barnard" <dumbardos@b...> on Mon, 11 Mar 2002 14:32:51
> Field :NonNullableField

> Attrib:202

> Nullable :False

> -------------------------------------------------------------------------

---

> ----

> Field :NullableField

> Attrib:234

> Nullable :True

> 

> -----Original Message-----



Hi Eric,



Please can you tell me

Your OS version (Win98/NT4/2000 etc)

IIS version

Odbc32.dll version (in c:\windows\system or system32)



Thanks for testing the code much appriciated.

Message #4 by "Alex Barnard" <dumbardos@b...> on Mon, 11 Mar 2002 18:30:39
Ian's Reply - correct response.



> OS =  Win98

> IIS = PWS

> odbc32.dll version = 3.520.6526.0

> 

> results below:

> 

> Field :NonNullableField

> Attrib:202

> Nullable :False

> -------------------------------------------------------------------------

---

> ----

> Field :NullableField

> Attrib:234

> Nullable :True

> 



Thanks to all of you who are replying. Keep them coming. This is most 

interesting.



Ian Morrison, you have the correct result. You have the same MDAC version 

as I do 3.52 (as odbc32.dll) and use the same IIS server. But I get a 

FALSE and Attrib:234 for both fields - incorrect.



Tim Morford you are in the same boat as I am with Win2K SP2. My internet 

sever is the same as yours and upgraded to SP2 and for me the script no 

longer works. It gives a false to both fields. It should give you the 

result as Ian has (above).



Also James Garrett, all apears to be well on your NT4 server, but can you 

please let me know what your odbc32.dll version is. (c:\winnt\system32 as 

a guess) 



Perhaps the gurus at Wrox can fathom what's going on here. Keep replying.
Message #5 by "James Garrett" <jhgarrett@e...> on Mon, 11 Mar 2002 10:46:30 -0500
My odbc32.dll is version 3.510.37110.0



James



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

From: "Alex Barnard" <dumbardos@b...>

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

Sent: Monday, March 11, 2002 6:30 PM

Subject: [asp_databases] Re: Everyone try this code...





> Ian's Reply - correct response.

>

> > OS =  Win98

> > IIS = PWS

> > odbc32.dll version = 3.520.6526.0

> >

> > results below:

> >

> > Field :NonNullableField

> > Attrib:202

> > Nullable :False

>

> -------------------------------------------------------------------------

> ---

> > ----

> > Field :NullableField

> > Attrib:234

> > Nullable :True

> >

>

> Thanks to all of you who are replying. Keep them coming. This is most

> interesting.

>

> Ian Morrison, you have the correct result. You have the same MDAC version

> as I do 3.52 (as odbc32.dll) and use the same IIS server. But I get a

> FALSE and Attrib:234 for both fields - incorrect.

>

> Tim Morford you are in the same boat as I am with Win2K SP2. My internet

> sever is the same as yours and upgraded to SP2 and for me the script no

> longer works. It gives a false to both fields. It should give you the

> result as Ian has (above).

>

> Also James Garrett, all apears to be well on your NT4 server, but can you

> please let me know what your odbc32.dll version is. (c:\winnt\system32 as

> a guess)

>

> Perhaps the gurus at Wrox can fathom what's going on here. Keep replying.




$subst('Email.Unsub').



Message #6 by "James Garrett" <jhgarrett@e...> on Mon, 11 Mar 2002 08:09:08 -0500
OS: NT 4.0 SP5

IIS: 1.1

ODBC: ODBC32



got different results:

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

 Field :NonNullableField

 Attrib:202

 Nullable :False

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

 Field :NullableField

 Attrib:234

 Nullable :True

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



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

From: "Alex Barnard" <dumbardos@b...>

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

Sent: Monday, March 11, 2002 1:35 PM

Subject: [asp_databases] Everyone try this code...





> Anyone reading this please try the code below. It will only take 5 mins of

> your time but it is very important.

>

> All you have to do is copy and paste the code (between ========) into a

> blank text file anywhere on you Webserver (e.g. c:\inetpub\wwwroot) and

> call it "nulltest.asp"

>

> Open a browser and load the test ASP file "nulltest.asp"

> e.g. http://127.0.0.1/nulltest.asp

>

> The code will create the following database "C:\adoNullTest.mdb" delete

> this file once you have finished testing.

>

> I get the following result displayed in my browser window.......

>

> ---------------------------------------------------------

> Field :NonNullableField

> Attrib:234

> Nullable :True

> ---------------------------------------------------------

> Field :NullableField

> Attrib:234

> Nullable :True

> ---------------------------------------------------------

>

> Please paste your results as a reply to this thread. The more of you who

> reply, the better our understanding of ADO and ODBC database connectivity.

>

> Many thanks for your time. And for the geniuses out there, tell us all why

> these results are wrong....

>

> THE CODE (copy between =====)

> ====================================================

> <%

> Option Explicit

> const DB_PATH="C:\adoNullTest.mdb"

> Const adOpenStatic = 3

> Const adLockReadOnly = 1

> Const adFldIsNullable = &H00000020

>

> Dim conn,dbString,rs,FSYS,newdb,fld

>

> 'CHECK EXISTING EXAMPLE DB EXISTS

> set FSYS=createobject("Scripting.FilesystemObject")

> if FSYS.fileexists(DB_PATH) then

> 'DELETE TEST DB

> FSYS.deletefile DB_PATH

> end if

>

> 'CREATE TEST DATABASE

> dbString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&DB_PATH&";"

> Set newdb = Server.CreateObject("ADOX.Catalog")

> newdb.create dbString

> set newdb=nothing

>

> 'THE REAL STUFF STARTS HERE......................

>

> 'OPEN DB CONNECTION OBJECT

> Set conn = Server.CreateObject("ADODB.Connection")

> conn.Open dbString

> 'CREATE TABLE+FIELDS 1)NONNULLABLE 2)NULLABLE

> conn.Execute "CREATE TABLE AdoNullableTest " & _

>                 "(NonNullableField TEXT NOT NULL, NullableField TEXT)"

>

> ' Open a recordset on the new table - I use a Query rather then a table

> '(adCmdTable) as I need to use SQL commands.

> set rs = Server.CreateObject("ADODB.Recordset")

> rs.Open "SELECT * FROM AdoNullableTest",conn,adOpenStatic,adLockReadOnly

> 'LOOP FOR EACH FIELD IN DB

> for each fld in rs.Fields

> 'SHOW NAME-VALUE-NULLABILITY

> response.write "<b>Field</b> :" & fld.Name & "<BR>"

> response.write "<b>Attrib</b>:" & fld.Attributes & "<BR>"

> response.write "<b>Nullable</b> :"&((fld.Attributes and _

>     adFldIsNullable)=adFldIsNullable)&"<hr>"

> Next

> 'CLEAR UP

> rs.Close

> conn.close

> set fSYS=nothing

> set rs=nothing

> set conn=nothing

> %>

> ========================================================================

>




$subst('Email.Unsub').

>



Message #7 by "Tim Morford" <tmorford@n...> on Mon, 11 Mar 2002 10:16:30 -0500
OS:Win2K SP2

IIS: 5.0

odbc32.dll: 3.520.7713.0



Field :NonNullableField

Attrib:234

Nullable :True

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

----

Field :NullableField

Attrib:234

Nullable :True



Tim Morford



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

From: Ian Richardson [mailto:ian@i...]

Sent: Monday, March 11, 2002 10:03 AM

To: ASP Databases

Subject: [asp_databases] Re: Everyone try this code...





OS =  Win98

IIS = PWS

odbc32.dll version = 3.520.6526.0



results below:



Field :NonNullableField

Attrib:202

Nullable :False

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

----

Field :NullableField

Attrib:234

Nullable :True





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

From: "Alex Barnard" <dumbardos@b...>

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

Sent: Monday, March 11, 2002 1:35 PM

Subject: [asp_databases] Everyone try this code...





> Anyone reading this please try the code below. It will only take 5 mins of

> your time but it is very important.

>

> All you have to do is copy and paste the code (between ========) into a

> blank text file anywhere on you Webserver (e.g. c:\inetpub\wwwroot) and

> call it "nulltest.asp"

>

> Open a browser and load the test ASP file "nulltest.asp"

> e.g. http://127.0.0.1/nulltest.asp

>

> The code will create the following database "C:\adoNullTest.mdb" delete

> this file once you have finished testing.

>

> I get the following result displayed in my browser window.......

>

> ---------------------------------------------------------

> Field :NonNullableField

> Attrib:234

> Nullable :True

> ---------------------------------------------------------

> Field :NullableField

> Attrib:234

> Nullable :True

> ---------------------------------------------------------

>

> Please paste your results as a reply to this thread. The more of you who

> reply, the better our understanding of ADO and ODBC database connectivity.

>

> Many thanks for your time. And for the geniuses out there, tell us all why

> these results are wrong....

>

> THE CODE (copy between =====)

> ====================================================

> <%

> Option Explicit

> const DB_PATH="C:\adoNullTest.mdb"

> Const adOpenStatic = 3

> Const adLockReadOnly = 1

> Const adFldIsNullable = &H00000020

>

> Dim conn,dbString,rs,FSYS,newdb,fld

>

> 'CHECK EXISTING EXAMPLE DB EXISTS

> set FSYS=createobject("Scripting.FilesystemObject")

> if FSYS.fileexists(DB_PATH) then

> 'DELETE TEST DB

> FSYS.deletefile DB_PATH

> end if

>

> 'CREATE TEST DATABASE

> dbString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&DB_PATH&";"

> Set newdb = Server.CreateObject("ADOX.Catalog")

> newdb.create dbString

> set newdb=nothing

>

> 'THE REAL STUFF STARTS HERE......................

>

> 'OPEN DB CONNECTION OBJECT

> Set conn = Server.CreateObject("ADODB.Connection")

> conn.Open dbString

> 'CREATE TABLE+FIELDS 1)NONNULLABLE 2)NULLABLE

> conn.Execute "CREATE TABLE AdoNullableTest " & _

>                 "(NonNullableField TEXT NOT NULL, NullableField TEXT)"

>

> ' Open a recordset on the new table - I use a Query rather then a table

> '(adCmdTable) as I need to use SQL commands.

> set rs = Server.CreateObject("ADODB.Recordset")

> rs.Open "SELECT * FROM AdoNullableTest",conn,adOpenStatic,adLockReadOnly

> 'LOOP FOR EACH FIELD IN DB

> for each fld in rs.Fields

> 'SHOW NAME-VALUE-NULLABILITY

> response.write "<b>Field</b> :" & fld.Name & "<BR>"

> response.write "<b>Attrib</b>:" & fld.Attributes & "<BR>"

> response.write "<b>Nullable</b> :"&((fld.Attributes and _

>     adFldIsNullable)=adFldIsNullable)&"<hr>"

> Next

> 'CLEAR UP

> rs.Close

> conn.close

> set fSYS=nothing

> set rs=nothing

> set conn=nothing

> %>

> ========================================================================

>




$subst('Email.Unsub').








$subst('Email.Unsub').



Message #8 by "Ian Richardson" <ian@i...> on Mon, 11 Mar 2002 15:02:41 -0000
OS =  Win98

IIS = PWS

odbc32.dll version = 3.520.6526.0



results below:



Field :NonNullableField

Attrib:202

Nullable :False

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

----

Field :NullableField

Attrib:234

Nullable :True





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

From: "Alex Barnard" <dumbardos@b...>

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

Sent: Monday, March 11, 2002 1:35 PM

Subject: [asp_databases] Everyone try this code...





> Anyone reading this please try the code below. It will only take 5 mins of

> your time but it is very important.

>

> All you have to do is copy and paste the code (between ========) into a

> blank text file anywhere on you Webserver (e.g. c:\inetpub\wwwroot) and

> call it "nulltest.asp"

>

> Open a browser and load the test ASP file "nulltest.asp"

> e.g. http://127.0.0.1/nulltest.asp

>

> The code will create the following database "C:\adoNullTest.mdb" delete

> this file once you have finished testing.

>

> I get the following result displayed in my browser window.......

>

> ---------------------------------------------------------

> Field :NonNullableField

> Attrib:234

> Nullable :True

> ---------------------------------------------------------

> Field :NullableField

> Attrib:234

> Nullable :True

> ---------------------------------------------------------

>

> Please paste your results as a reply to this thread. The more of you who

> reply, the better our understanding of ADO and ODBC database connectivity.

>

> Many thanks for your time. And for the geniuses out there, tell us all why

> these results are wrong....

>

> THE CODE (copy between =====)

> ====================================================

> <%

> Option Explicit

> const DB_PATH="C:\adoNullTest.mdb"

> Const adOpenStatic = 3

> Const adLockReadOnly = 1

> Const adFldIsNullable = &H00000020

>

> Dim conn,dbString,rs,FSYS,newdb,fld

>

> 'CHECK EXISTING EXAMPLE DB EXISTS

> set FSYS=createobject("Scripting.FilesystemObject")

> if FSYS.fileexists(DB_PATH) then

> 'DELETE TEST DB

> FSYS.deletefile DB_PATH

> end if

>

> 'CREATE TEST DATABASE

> dbString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&DB_PATH&";"

> Set newdb = Server.CreateObject("ADOX.Catalog")

> newdb.create dbString

> set newdb=nothing

>

> 'THE REAL STUFF STARTS HERE......................

>

> 'OPEN DB CONNECTION OBJECT

> Set conn = Server.CreateObject("ADODB.Connection")

> conn.Open dbString

> 'CREATE TABLE+FIELDS 1)NONNULLABLE 2)NULLABLE

> conn.Execute "CREATE TABLE AdoNullableTest " & _

>                 "(NonNullableField TEXT NOT NULL, NullableField TEXT)"

>

> ' Open a recordset on the new table - I use a Query rather then a table

> '(adCmdTable) as I need to use SQL commands.

> set rs = Server.CreateObject("ADODB.Recordset")

> rs.Open "SELECT * FROM AdoNullableTest",conn,adOpenStatic,adLockReadOnly

> 'LOOP FOR EACH FIELD IN DB

> for each fld in rs.Fields

> 'SHOW NAME-VALUE-NULLABILITY

> response.write "<b>Field</b> :" & fld.Name & "<BR>"

> response.write "<b>Attrib</b>:" & fld.Attributes & "<BR>"

> response.write "<b>Nullable</b> :"&((fld.Attributes and _

>     adFldIsNullable)=adFldIsNullable)&"<hr>"

> Next

> 'CLEAR UP

> rs.Close

> conn.close

> set fSYS=nothing

> set rs=nothing

> set conn=nothing

> %>

> ========================================================================

>




$subst('Email.Unsub').



Message #9 by "Eric Van Camp" <eric@a...> on Mon, 11 Mar 2002 14:46:20 +0100
Field :NonNullableField

Attrib:202

Nullable :False

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

----

Field :NullableField

Attrib:234

Nullable :True



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

From: Alex Barnard [mailto:dumbardos@b...]

Sent: Monday, March 11, 2002 13:35

To: ASP Databases

Subject: [asp_databases] Everyone try this code...





Anyone reading this please try the code below. It will only take 5 mins of

your time but it is very important.



All you have to do is copy and paste the code (between ========) into a

blank text file anywhere on you Webserver (e.g. c:\inetpub\wwwroot) and

call it "nulltest.asp"



Open a browser and load the test ASP file "nulltest.asp"

e.g. http://127.0.0.1/nulltest.asp



The code will create the following database "C:\adoNullTest.mdb" delete

this file once you have finished testing.



I get the following result displayed in my browser window.......



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

Field :NonNullableField

Attrib:234

Nullable :True

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

Field :NullableField

Attrib:234

Nullable :True

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



Please paste your results as a reply to this thread. The more of you who

reply, the better our understanding of ADO and ODBC database connectivity.



Many thanks for your time. And for the geniuses out there, tell us all why

these results are wrong....



THE CODE (copy between =====)

====================================================

<%

Option Explicit

const DB_PATH="C:\adoNullTest.mdb"

Const adOpenStatic = 3

Const adLockReadOnly = 1

Const adFldIsNullable = &H00000020



Dim conn,dbString,rs,FSYS,newdb,fld



'CHECK EXISTING EXAMPLE DB EXISTS

set FSYS=createobject("Scripting.FilesystemObject")

if FSYS.fileexists(DB_PATH) then

	'DELETE TEST DB

	FSYS.deletefile DB_PATH

end if



'CREATE TEST DATABASE

dbString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&DB_PATH&";"

Set newdb = Server.CreateObject("ADOX.Catalog")

newdb.create dbString

set newdb=nothing



'THE REAL STUFF STARTS HERE......................



'OPEN DB CONNECTION OBJECT

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

conn.Open dbString

'CREATE TABLE+FIELDS 1)NONNULLABLE 2)NULLABLE

conn.Execute "CREATE TABLE AdoNullableTest " & _

                "(NonNullableField TEXT NOT NULL, NullableField TEXT)"



' Open a recordset on the new table - I use a Query rather then a table

'(adCmdTable) as I need to use SQL commands.

set rs = Server.CreateObject("ADODB.Recordset")

rs.Open "SELECT * FROM AdoNullableTest",conn,adOpenStatic,adLockReadOnly

'LOOP FOR EACH FIELD IN DB

for each fld in rs.Fields

	'SHOW NAME-VALUE-NULLABILITY

	response.write "<b>Field</b> :" & fld.Name & "<BR>"

	response.write "<b>Attrib</b>:" & fld.Attributes & "<BR>"

	response.write "<b>Nullable</b> :"&((fld.Attributes and _

    adFldIsNullable)=adFldIsNullable)&"<hr>"

Next

'CLEAR UP

rs.Close

conn.close

set fSYS=nothing

set rs=nothing

set conn=nothing

%>

========================================================================






$subst('Email.Unsub').




  Return to Index