fix dialog and sql
add sql for db