Dim Result As DialogResult Result = MessageBox.Show("需要保存吗?", "提示", MessageBoxButtons.Yesno, MessageBoxIcon.Question) If Result = DialogResult.Yes Then Dim T1,T2,T3,T4,T5 As String T1="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=跟单系统;Data Source=wxd" T2= "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=项目列表;Data Source=wxd" T3="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=装箱单;Data Source=wxd" T4="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=面料出库;Data Source=wxd" T5="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=排期表;Data Source=wxd" Dim Names(4) As String Names (0) =t1 Names (1) = t2 Names (2) = t3 Names (3) = t4 Names (4) = t5 Dim C1 As New Data.Oledb.OledbConnection(Names(4)) Try C1.Open() C1.Close() Syscmd.Project.Exit(True) Catch ex as Exception MessageBox.Show("服务器已关闭,无法保存后退出,请开启服务器!","警告!!!") End Try else Syscmd.Project.Exit(False) End If
这个是我做的退出系统的代码,里面有一段判断外部数据源是否关闭的代码.你自己根据需要修改一下.
|