vb.net压缩数据库 vba压缩指定文件夹

请问关于用vb.net语句操作数据库的问题“也就是说这个查询出来的结果是个临时的表”貌似你的说法不太对 你的select里还有写如临时表吗?
可以直接放到dataset里啊

dataadapter.selectcommand.text="select top 3 * from xxx"(好像这个属性是commandtext 忘了)
dataadapter.fill(dataset)就可以啊
在VB中压缩SQL数据库首先在master库中,新建存储过程
CREATE PROCEDUREp_compdb
@dbname sysname--要压缩的数据库名
as
--1.清空日志
exec('DUMP TRANSACTION [' @dbname '] WITHNO_LOG')
--2.截断事务日志:
exec('BACKUP LOG [' @dbname '] WITH NO_LOG')
--3.收缩数据库文件(如果不压缩,数据库的文件不会减小
exec('DBCC SHRINKDATABASE([' @dbname '])')
--4.设置自动收缩
exec('EXEC sp_dboption ''' @dbname ''',''autoshrink'',''TRUE''')
GO
然后在VB中调用,参数是数据库名 。
需要用访问master库的权限连接到master库上调用 。
try this:
command.Execute("sp_dboption '" 数据库名 "'")
关于vb.net上数据库的使用问题你把数据库中的数据查询出来保存在DataSet 中
DataSet 是脱机的数据集,也即与数据库断开的数据集
把DataSet绑定到GridView上,这时候你在GridView上的操作就都是与数据库断开的
vb.net 怎么操作数据库如果楼主熟悉VB6,可以直接在项目中添加ADODB的Com引用 , 这样你就可以像VB6那样操作数据库了!
另外
.NET
Framework中连接数据库要用到ADO.NET 。如果要操作Access数据库,要用到System.Data.OleDb命名空间下的许多类 。
比如按楼主所说,“我想在textbox1中显示表一中【一些数据】字段下的第一个内容”:
'首先导入命名空间
Imports
System.Data
Imports
System.Data.OleDb
'然后在某一个事件处理程序中写:
Dim
conn
As
New
OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=数据库.accdb;Jet
OLEDB:Database
Password=MyDbPassword")
Dim
command
As
New
OleDbCommand("Select
*
From
数据表",
conn)
conn.Open()
'打开数据库连接
Dim
reader
As
OleDbDataReader
=
command.ExecuteReader()
'执行SQL语句 , 返回OleDbDataReader
对象
Do
While
reader.Read()
'读取一条数据
textbox1.Text
=
reader("一些数据")
VbCrLf
Loop
reader.Close()
'关闭OleDbDataReader
conn.Close()
'关闭连接
VB.NET 数据库操作真vb.net压缩数据库的要学习 就自己去一条条vb.net压缩数据库的找结果 在csnd上很多很多的vb.net压缩数据库 , vb.net压缩数据库你的编译出来如果是64 那在32位机器可能不能用 或者JET不支持vb.net压缩数据库,
用vb.net对sql多数据库压缩备份为一个文件using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using _5dRss.Const;
using _5dRss.lib.Data.Tool;
public partial class admin_admin_dbmanage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//生成备份文件列表
ListBackupFiles();
if (!Page.IsPostBack)
{
Showmsg.Visible = false;
//数据库路径
lilDBPath.Text = HttpContext.Current.Request.PhysicalApplicationPath"App_Data\\"ConfigurationSettings.AppSettings["DBFile"];
//新建一个 FileInfo 对象,并获得数据库文件的大?。缓笞坏ノ晃狵B
FileInfo myFileInfo = new FileInfo(lilDBPath.Text);
lilDBSize.Text = Convert.ToString(myFileInfo.Length/1024)" KB";
//如果两个参数都不为空 , 则继续执行
【vb.net压缩数据库 vba压缩指定文件夹】if (Request.QueryString["cmd"] != nullRequest.QueryString["source"] != null)
{
//备份数据库原文件名
string sourceFileName = Request.QueryString["source"];
//如果 cmd 参数为 DelFile
if (Request.QueryString["cmd"].Equals("DelFile"))
{
//删除备份数据库文件
File.Delete(HttpContext.Current.Request.PhysicalApplicationPath"Backup\\"sourceFileName);
//刷新备份文件列表
ListBackupFiles();
Showmsg.Visible = true;
Showmsg.Text = "div align='center' style='margin-bottom:8px;'img src='https://www.04ip.com/post/images/aL.gif' style='margin-bottom:-6px;'/span class='alertTxt'删除备份数据库成功!/spanimg src='https://www.04ip.com/post/images/aR.gif' style='margin-bottom:-6px;'//div";
}
//如果 cmd 参数为 Restore
if (Request.QueryString["cmd"].Equals("Restore"))
{
//用备份文件覆盖原文件
File.Copy(HttpContext.Current.Request.PhysicalApplicationPath"Backup\\"sourceFileName, HttpContext.Current.Request.PhysicalApplicationPath"App_Data\\"ConfigurationSettings.AppSettings["DBFile"], true);
//刷新备份文件列表
ListBackupFiles();
Showmsg.Visible = true;
Showmsg.Text = "div align='center' style='margin-bottom:8px;'img src='https://www.04ip.com/post/images/aL.gif' style='margin-bottom:-6px;'/span class='alertTxt'还原备份数据库成功!/spanimg src='https://www.04ip.com/post/images/aR.gif' style='margin-bottom:-6px;'//div";
}
}
}
}
protected void lnkbtnCompactDB_Click(object sender, EventArgs e)
{
//压缩修复数据库
AccessDBtool.CompactAccessDB(SysConfig.ConnectionString, HttpContext.Current.Request.PhysicalApplicationPath"App_Data\\"ConfigurationSettings.AppSettings["DBFile"]);
Showmsg.Visible = true;
Showmsg.Text = "div align='center' style='margin-bottom:8px;'img src='https://www.04ip.com/post/images/aL.gif' style='margin-bottom:-6px;'/span class='alertTxt'压缩修复数据库成功!/spanimg src='https://www.04ip.com/post/images/aR.gif' style='margin-bottom:-6px;'//div";
}
protected void lnkbtnBackupDB_Click(object sender, EventArgs e)
{
string sourceFileName = HttpContext.Current.Request.PhysicalApplicationPath"App_Data\\"ConfigurationSettings.AppSettings["DBFile"];
string destFileName = HttpContext.Current.Request.PhysicalApplicationPath"Backup\\""Backup_";
destFileName= DateTime.Now.ToString("yyyyMMddHHmmss");
destFileName= ".mbk";
//将数据库文件Copy到Backup目录,如果有重名文件就覆盖原文件
File.Copy(sourceFileName, destFileName, true);
//生成备份文件列表
ListBackupFiles();
Showmsg.Visible = true;
Showmsg.Text = "div align='center' style='margin-bottom:8px;'img src='https://www.04ip.com/post/images/aL.gif' style='margin-bottom:-6px;'/span class='alertTxt'备份数据库成功!/spanimg src='https://www.04ip.com/post/images/aR.gif' style='margin-bottom:-6px;'//div";
}
/// summary
/// 生成备份文件列表
/// /summary
/// returns文件列表,文件详细信息及操作选项的HTML代码/returns
public void ListBackupFiles()
{
//如果目录不存在则创建次目录
if (!Directory.Exists(HttpContext.Current.Request.PhysicalApplicationPath"Backup\\"))
Directory.CreateDirectory(HttpContext.Current.Request.PhysicalApplicationPath"Backup\\");
DirectoryInfo mydir = new DirectoryInfo(HttpContext.Current.Request.PhysicalApplicationPath"Backup\\");
StringBuilder sb = new StringBuilder();
foreach (FileInfo f in mydir.GetFiles())
{
sb.Append("a href='https://www.04ip.com/post/backup/"f.Name"' target='_blank'img border='0' src='https://www.04ip.com/post/images/mdb.gif' style='margin:4px 3px -3px 0px'/"f.Name"/aa href='https://www.04ip.com/post/?cmd=DelFilesource="f.Name"' title='删除备份文件'删除/a | a href='https://www.04ip.com/post/?cmd=Restoresource="f.Name"' title='删除备份文件'还原数据库/a | "f.Length/1024" KB | "f.CreationTime"br /");
}
lilBackupFileList.Text = sb.ToString();
}
}
把下面这句换成你的数据库地址:
//数据库路径
//lilDBPath.Text = HttpContext.Current.Request.PhysicalApplicationPath"App_Data\\"ConfigurationSettings.AppSettings["DBFile"];
vb.net压缩数据库的介绍就聊到这里吧 , 感谢你花时间阅读本站内容 , 更多关于vba压缩指定文件夹、vb.net压缩数据库的信息别忘了在本站进行查找喔 。

    推荐阅读