用编程发方式实现
假设有这样一个数据表info
unid (主键) name pwd age sex
1 小华 12345 空值 空值
2 小明 空值 12 女
先定义一个函数
public function executesql(byval sql as string) as boolean
try
dim myconn as sqlconnection=new (connstr)
myconn.open
dim mycomm as sqlcommand=new (sql,myconn)
mycomm.executenonquery()
return true
catch ex as exception
return false
end try
dim myda as sqldataadapter
myda=new sqldataadapter("select * from info",myconn)
dim ds as dataset=new dataset()
myda.fill(ds,"my")
dim i as integer
dim k as integer
for i=o to ds.tables("my").rows.count-1
dim unid as integer
unid=ds.tables("my").rows(i)(0)
for k=0 to ds.tables("my").columns.count-1
if isnull(ds.tables("my").rows(i).item(k)) then
sql="update info set "&ds.tables("my").columns.item(k).columnname &"=0 where unid="&unid
executesql(sql)
end if
next
next
我没有运行过就是在这里面写的
不知道有没有错误!
觉得应该可以实现