Cannot Get Field Nullable Property

P

Paul Eaton

Hi

I am using asp/vbscript/ado/mssql.

I am able to get the nullable property OK when generating a recordset
with a simple SQL statement such as "select Fld1,Fld2 from Table1" and
then looping thro' the fields and :-

Response.Write(rs.fields(x).attributes and adFldIsNullable)

When I use the following statement all fields are erroneously reported
as nullable:-

"Select B.Fld2, B.Fld3 From Table1 A Left Join Table2 B On
A.Fld1=B.Fld1"

Is this normal?
 
B

Bob Barrows

This recordset may not even be updatable, and you're worried about whether
or not the fields are nullable?

If you set the Unique Table dynamic property, you may get the true results
for the fields. You can only set this property if you use a client-side
cursor (adUseClient). I have no idea if this will work. I've never tried to
update a recordset whose source was a multi-table select statement.

Bob Barrows
 
A

Aaron Bertrand - MVP

Do you need to get the *data* in order to get the metadata? How about
grabbing the column names and whether they are NULL or not from the I_S
view:

sql = "SELECT COLUMN_NAME, IS_NULLABLE " & _
" FROM INFORMATION_SCHEMA.COLUMNS " & _
" WHERE TABLE_NAME='Table1'"
set rs = conn.execute(sql)
do while not rs.eof
response.write rs(0) & " nullable? " & rs(1) & "<br>"
rs.movenext
loop
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top