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=zhujian"
T2= "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=项目列表;Data Source=zhujian"
T3="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=装箱单;Data Source=zhujian"
T4="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=面料出库;Data Source=zhujian"
T5="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=排期表;Data Source=zhujian"
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.Save()
Syscmd.Project.Exit()
Catch ex As Exception
MessageBox.Show("服务器已关闭,无法保存后退出,请开启服务器!","警告!!!")
End Try
Else
Syscmd.Project.Exit(False)
End If
这个代码是我要退出系统时,判断服务器有没有关闭的代码,你修改着用!