C#access数据库操作
比较凌乱,有时间在整理吧。
Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data source=c:/D.mdb;Jet OLEDB:DataBase Password=!" private void GetCon()
{
string strConnection="PRovider=Microsoft.Jet.OleDb.4.0;";
strConnection+=@"Data Source=C:\BegaspNET\Northwind.mdb"; OleDbConnection objConnection=new OleDbConnection(strConnection); objConnection.Open();
objConnection.Close(); }
以独占的方式打开
文件--信息--加密/解密
PRovider=Microsoft.Jet.OleDb.4.0;Jet OLEDB:DataBase Password=;Data Source=D:\ToWife.mdb;
.
set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
DBPath = Server.MapPath("customer.mdb")
dbconnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
SQL="select * from auth where id="" & user_id &"""
SET uplist=dbconnection.EXECUTE(SQL) .
set dbconnection=Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("customer.mdb")
dbconnection.Open "provider=microsoft.jet.oledb.4.0;data source="&dbpath
SQL="select * from auth where id="" & user_id &"""
SET uplist=dbconnection.EXECUTE(SQL) .
DBPath = Server.MapPath("customer.mdb")
set session("rs")=Server.CreateObject("ADODB.Recordset")
" rs=Server.CreateObject("ADODB.Recordset")
connstr="provider=microsoft.jet.oledb.4.0;data source="&dbpath
SQL="select * from auth where id="" & user_id &"""
session("rs").Open sql,connstr,,
连接access2007
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=D:/数据库.accdb;Jet OLEDB:Database Password=123456;
连接access2003
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin";Data Source=D:/数据库.mdb;Jet OLEDB:Database password=;")
建odbc源
set conn=server.createobject("Adodb.connection")
conn.open "DSN=xxx;UID=;PWD=123456;Database=XXX"
破解密码
public static string GetMDBPassword(string file)
{
// 未加密的MDB文件,0x42到0x61之间的每间隔一字节的数值
byte[] baseByte = { 0xbe, 0xec, 0x65, 0x9c, 0xfe, 0x28, 0x2b, 0x8a, 0x6c, 0x7b, 0xcd, 0xdf, 0x4f, 0x13, 0xf7, 0xb1, };
byte flagByte = 0x0c; // 标志 0x62 处的数值
string password = "";
try
{
FileStream fs = File.OpenRead(file);
fs.Seek(0x14, SeekOrigin.Begin);
byte ver = (byte)fs.ReadByte(); // 取得access版本, 1为Access2000/2003, 0为Access97
fs.Seek(0x42, SeekOrigin.Begin);
byte[] bs = new byte[];
if (fs.Read(bs, , ) != ) return "";
byte flag = (byte)(bs[] ^ flagByte);
for (int i = ; i < ; i++)
{
byte b = (byte)(baseByte[i] ^ bs[i * ]);
if (i % == && ver == ) b ^= flag; //Access 2000/2003
if (b > ) password += (char)b;
}
}
catch { } return ( password.Equals( "" ) ? "没有密码!" : password );
}
up
private int up(string sql)
{
int index = ;
OleDbConnection con = GetCon();
try
{
if (con!=null)
{
con.Open();
OleDbCommand oc = new OleDbCommand(sql, con);
return oc.ExecuteNonQuery();
}
return ;
}
catch (Exception)
{
return ;
}
}
select
private DataTable select(string sql)
{
DataTable dt = new DataTable();
OleDbConnection con = GetCon();
try
{
if (con!=null)
{
con.Open();
//用 OleDbDataAdapter 得到一个数据集
OleDbDataAdapter myCommand = new OleDbDataAdapter(sql,con);
DataSet myDataSet = new DataSet();
//把Dataset绑定books数据表
myCommand.Fill(myDataSet);
con.Close();
return myDataSet.Tables[];
}
con.Close();
return null;
}
catch (Exception)
{
con.Close();
return null;
}
}
主键的操作
Function AddPrimaryKey()
'添加主键到[编号]字段
Dim strSQL As String
strSQL = "ALTER TABLE 表1 ADD CONSTRAINT PRIMARY_KEY " _
& "PRIMARY KEY (编号)"
CurrentProject.Connection.Execute strSQL
End Function Function DropPrimaryKey()
'删除主键
Dim strSQL As String
strSQL = "ALTER TABLE 表1 Drop CONSTRAINT PRIMARY_KEY "
CurrentProject.Connection.Execute strSQL
End Function
C#access数据库操作的更多相关文章
- C# ACCESS数据库操作类
这个是针对ACCESS数据库操作的类,同样也是从SQLHELPER提取而来,分页程序的调用可以参考MSSQL那个类的调用,差不多的,只是提取所有记录的数量的时候有多一个参数,这个需要注意一下! usi ...
- Microsoft Access数据库操作类(C#)
博文介绍的Microsoft Access数据库操作类是C#语言的,可实现对Microsoft Access数据库的增删改查询等操作.并且该操作类可实现对图片的存储,博文的最后附上如何将Image图片 ...
- C# 对Access数据库操作的通用类
(转载自博主Jerry很简单) //Access数据库-C# 操作类 代码using System;using System.Collections.Generic;using System.Linq ...
- C#对SQLite、Access数据库操作的封装,很好用的~
1.对SQLite的封装: using System; using System.Collections.Generic; using System.Linq; using System.Text; ...
- asp.net mvc access数据库操作
连接access数据库其实也简单,只要按照mvc的模式来就可以,遵循c v约定就可以 既然渲染试图是强类型,那么取得的数据就转换成强类型,其他一切和asp.net操作一样 DB mydb = new ...
- C#---数据库访问通用类、Access数据库操作类、mysql类 .[转]
原文链接 //C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using Sy ...
- C#---数据库访问通用类、Access数据库操作类、mysql类 .
//C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using System. ...
- C# 动软生成器对应的Access数据库操作类DbHelperOleDb
using System;using System.Collections;using System.Collections.Specialized;using System.Data;using S ...
- 一个基于ASP.NET(C#)的ACCESS数据库操作类
using System; using System.Collections; using System.Collections.Specialized; using System.Data; usi ...
随机推荐
- asp.net uploadfile 上传文件,连接已重置问题
修改web.config中的配置 <httpRuntime maxRequestLength="/> //设置上传文件大小(kb)和响应时间(s) 针对iis7或更高版本另需要在 ...
- 【.Net】从.NET平台调用Win32 API
小序 Win32 API可以直接控制Microsoft Windows的核心,因为API(Application Programming Interface)本来就是微软留给我们直接控制 ...
- java之方法覆盖的坑
昨天写了个小例子,覆盖hashCode.equals进行集合set的一些特性测试,代码如下: class Test3 { public int c; public Test3(int c) {this ...
- Mongodb常见错误
1. log目录没有创建,而在logpath中有设定 2. SECONDARY默认不可以读取数据,需要db.getMongo().setSlaveOk(); 3. SECONDARY不可以写数据 4. ...
- const与重载
转载自CSDN博客:http://blog.csdn.net/polarbearboy/article/details/6762752 (由于该作者也属于转载,不知原出处) PS:我们很易对下面这 ...
- android玩耍(-) adbshell安装
一 什么是adbshell http://adbshell.com/ Android Debug Bridge (adb) is a command line tool that lets you c ...
- tornado 使用过程中提示‘no module name ioloop’
千万不要将程序文件命名为tornado.py 不然永远不会运行,因为运行后会在tornado.py里查找ioloop信息,永远找不到...
- jchat:linux聊天程序4:客户端
makefile: jchat: main.o login.o regist.o tcp.o gcc -w main.o login.o regist.o tcp.o -o jchat rm -f * ...
- @Html.ActionLink 添加样式 html标签
@Html.ActionLink(item.MessageTitle, "Detail", "News",new { MessageId = item.Mess ...
- MySQL的三层架构之一----连接层
1.mysql的服务端可以分为三层,分别是连接层,SQL层,存储层. 2.架构图 3.连接层定义了通信server端与client协议: