比较凌乱,有时间在整理吧。
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