我正在写一个程序,其中有写字段的值可以为空如下:
create table student_info
( studnet_id int not null primary key,
studnet_name char(10) null,
..... null
comment varchar(200) null,
)
当comment或其他字段的值为空时,出错text不能接受null
dim rs as adodb.recordset
strsql="select * from student_info"
rs.open strsql.........
text1.text=rs.fields(....)
text2.text=rs.fields(...)
....
textn.text=rs.fields(comment)
难道每个字段都要判断一下NULL再赋值吗?(如果有30个字段)有没有更好的办法(字段必须可以为空)
create table student_info
( studnet_id int not null primary key,
studnet_name char(10) null,
..... null
comment varchar(200) null,
)
当comment或其他字段的值为空时,出错text不能接受null
dim rs as adodb.recordset
strsql="select * from student_info"
rs.open strsql.........
text1.text=rs.fields(....)
text2.text=rs.fields(...)
....
textn.text=rs.fields(comment)
难道每个字段都要判断一下NULL再赋值吗?(如果有30个字段)有没有更好的办法(字段必须可以为空)
把所有的值to text
这样一来就不用考虑字段多少的问题
例如:toText(rs.fields("字段名").value)
没有totext的含义
小弟学浅,能否详细赐教
rs.open strsql.........
FOR I=0 TO 30
text1(I).text=rs.fields(I).VALUE &""
NEXT
text1.text=rs.fields(...)
end if
text1.text=trim(rs.fields(字段) & "")
dim rs as adodb.recordset
strsql="select * from student_info"
rs.open strsql.........
on error resume next
text1.text=rs.fields(....)
text2.text=rs.fields(...)
....
textn.text=rs.fields(comment)