扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
'得到SQL服务器的列表 '必须安装SQL SERVER 2000 SP2 及以上版本 Dim I As Short Dim sqlApp As New SQLDMO.Application() Dim ServerName As SQLDMO.NameList ServerName = sqlApp.ListAvailableSQLServers For i = 1 To ServerName.Count cbServer.Items.Add(ServerName.Item(i)) Next |
'得到指定SQL服务器所有数据库的列表 Dim sqlApp As New SQLDMO.Application() Dim oServer As New SQLDMO.SQLServer() oServer.Connect("(local)", "sa", "sa") cboDatabase.Items.Clear() Dim db As SQLDMO.Database For Each db In oServer.Databases Me.cboDatabase.Items.Add(db.Name) Next |
Dim I As Short Dim oServer As New SQLDMO.SQLServer() oServer.Connect("(local)", "sa", "sa") Dim db As New SQLDMO.Database() For I = 1 To oServer.Databases.Count If oServer.Databases.Item(I, "dbo").Name = "Northwind" Then Exit For Next If I > oServer.Databases.Count Then Exit Sub db = oServer.Databases.Item(I, "dbo") ListBox1.Items.Clear() '得到所有的存储过程 For I = 1 To db.StoredProcedures.Count ListBox1.Items.Add(db.StoredProcedures.Item(I, "dbo").Name) Next '得到所有的表 For I = 1 To db.Tables.Count ListBox1.Items.Add(db.Tables.Item(I, "dbo").Name) Next ' 得到所有的视图 For I = 1 To db.Views.Count ListBox1.Items.Add(db.Views.Item(I, "dbo").Name) Next |
'添加进度条ProgressBar1控件 '引用Microsoft SQLDMO Object Library '声明 Public WithEvents bkps As SQLDMO.Backup '数据库备份操作 Private Sub btnBackUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBackUp.Click Dim oSQLServer As New SQLDMO.SQLServer() oSQLServer.LoginSecure = False oSQLServer.Connect("(local)", "sa", "sa") '连接服务器 Me.Cursor = Windows.Forms.Cursors.WaitCursor bkps = CreateObject("SQLDMO.Backup") bkps.Database = "Northwind" '指定需备份的数据库 bkps.Action = 0 bkps.Files = "f:\Northwind.bak" '指定备份文件 bkps.Initialize = True ProgressBar1.Value = 0 ProgressBar1.Maximum = 100 Me.Cursor = Windows.Forms.Cursors.Default() Application.DoEvents() Dim mouseCur As Cursor Me.Cursor = Windows.Forms.Cursors.WaitCursor bkps.SQLBackup(oSQLServer) ProgressBar1.Value = 100 Application.DoEvents() bkps = Nothing Me.Cursor = Windows.Forms.Cursors.Default() MsgBox("数据库备份完成", MsgBoxStyle.Information, "系统消息") End Sub '显示进度 Private Sub bkps_PercentComplete(ByVal Message As String, ByVal Percent As Integer) Handles bkps.PercentComplete ProgressBar1.Value = ProgressBar1.Maximum * (Percent / 100) End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者