用VB.net做的管理软件,打开数据库时出现了点问题,麻烦各位前辈指教一下!
本帖最后由 bcrun 于 2013-09-24 21:13:47 编辑 点击打开按钮是弹出对话框,提示"当前文件未保存,是否保存",选择“是”之后,弹出保存对话框,可以将数据库文件保存在任意位置,但是保存之后紧接着会弹出打开对话框,不知道是哪里出现了问题!麻烦各位前辈指教一下,小弟感激不尽!
代码如下:
Dim ss As New SaveFileDialog数据库 vb.net 管理 对话框
Me.SaveFileDialog1.Filter = "数据库文件 (*.mdb)|*.mdb"
Me.SaveFileDialog1.InitialDirectory = "..\saveimg"
Me.SaveFileDialog1.DefaultExt = "mdb"
Me.SaveFileDialog1.FileName = "new.mdb"
ss.AddExtension = True
ss.DefaultExt = ".mdb"
If baocun = False Then
Dim Message As String = "当前文件未保存,是否保存?"
Dim Caption As String = "未保存"
Dim Buttons As Integer = MessageBoxButtons.YesNo
Dim Result As DialogResult = Windows.Forms.DialogResult.Yes
Result = MessageBox.Show(Me, Message, Caption, MessageBoxButtons.YesNo, _
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)
If Result = System.Windows.Forms.DialogResult.Yes Then
ss.FileName = "new.mdb"
userpath = ss.FileName
ss.ShowDialog()
If userpath.Length <> 0 Then
FileCopy(System.Windows.Forms.Application.StartupPath & "\new.mdb", ss.FileName)
End If
End If
End If
Kill(Application.StartupPath & "\new.mdb")
Dim dk As New OpenFileDialog
dk.DefaultExt = ".mdb"
dk.ShowDialog()
userpath = dk.FileName
If userpath.Length <> 0 Then
FileCopy(dk.FileName, Application.StartupPath & "\new.mdb")
End If
userpath = dk.FileName
nowpath = Application.StartupPath & "\new.mdb"
'连接数据库
Conn = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & nowpath & ";Persist Security Info=False;Jet OLEDB:Database Password=123"
OLEDBConnString = New System.Data.OleDb.OleDbConnection(Conn)