如题...
还有数据库里的主键是自动编号的.如果前面的被删除了,能不能让该主键自动收缩..
比如本来是1-2000.现在我删了1-1000.能不能让1001-2000的自动变成1-1000
还有数据库里的主键是自动编号的.如果前面的被删除了,能不能让该主键自动收缩..
比如本来是1-2000.现在我删了1-1000.能不能让1001-2000的自动变成1-1000
解决方案 »
- SetupDiEnumDeviceInterfaces返回false,错误259 C++范例程序正确,改为C#错误
- C#如何从获取到的网页内容中抓取自己想要的部分?
- s[1]和s.Substring(1,1)的区别
- 图形界面下调用console的应用程序的几个问题?
- 我想实现这样的控件怎么搞
- 关于Excel文件com模式读写多版本Excel的问题
- 用NUnit进行单体测试的问题
- string中字符的提取问题
- C#中MediaPlayer使用方法
- 如何将string转换成一个Byte数组?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11
- 关于类型转换出错的问题?
- listview中的checkbox可不可以设enabled=false
ID NAME
1001 __smallPig__ (小猪哼哼...) 另外一张表结构如下
ID Salary
1001 5000你改了数据后,变成
ID NAME
1001 无间道III其他的表就找不到先前的你了,你的钱就是我的了
/// MBD compact method (c) 2004 Alexander Youmashev
/// !!IMPORTANT!!
/// !make sure there's no open connections
/// to your db before calling this method!
/// !!IMPORTANT!!
/// </summary>
/// <param name="connectionString">connection string to your db</param>
/// <param name="mdwfilename">FULL name
/// of an MDB file you want to compress.</param>
public static void CompactAccessDB(string connectionString, string mdwfilename)
{
object[] oParams; //create an inctance of a Jet Replication Object
object objJRO =
Activator.CreateInstance(Type.GetTypeFromProgID("JRO.JetEngine")); //filling Parameters array
//cnahge "Jet OLEDB:Engine Type=5" to an appropriate value
// or leave it as is if you db is JET4X format (access 2000,2002)
//(yes, jetengine5 is for JET4X, no misprint here)
oParams = new object[] {
connectionString,
"Provider=Microsoft.Jet.OLEDB.4.0;Data" +
" Source=C:\\tempdb.mdb;Jet OLEDB:Engine Type=5"}; //invoke a CompactDatabase method of a JRO object
//pass Parameters array
objJRO.GetType().InvokeMember("CompactDatabase",
System.Reflection.BindingFlags.InvokeMethod,
null,
objJRO,
oParams); //database is compacted now
//to a new file C:\\tempdb.mdw
//let's copy it over an old one and delete it System.IO.File.Delete(mdwfilename);
System.IO.File.Move("C:\\tempdb.mdb", mdwfilename); //clean up (just in case)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objJRO);
objJRO=null;
}
Points of Interest
Interesting, that Jet Engine 5 is used for JET4X databases. Be careful. See the table:Jet OLEDB:Engine Type Jet x.x Format MDB Files
1 JET10
2 JET11
3 JET2X
4 JET3X
5 JET4X