获取Access用户定义的表名和各表的字段名
public static DataTable GetSchemaTable(string connectionString) //获取Access所有的表名;
{
using (OleDbConnection connection = new
OleDbConnection(connectionString))
{
connection.Open();
DataTable schemaTable = connection.GetOleDbSchemaTable(
OleDbSchemaGuid.Tables,
new object[] { null, null, null, "TABLE" });
return schemaTable;
}
}
private string[] GetTabelName(string conn) //获取Access文件中所有表名,放在数组里面
{
DataTable dt = GetSchemaTable(conn);
int n = dt.Rows.Count;
string[] strTable = new string[n];
int m = dt.Columns.IndexOf("TABLE_NAME");
for (int i = 0; i < n; i++)
 
相关文档:
查询语句只要这样写,就可以随机取出记录了
SQL="Select top 6 * from Dv_bbs1 where isbest = 1 and layer = 1 order by newID() desc"
在ACCESS里
SELECT top 15 id from tablename order by rnd(id)
SQL Server:
Select TOP N * from TABLE Order By NewID()
Access:
Select TOP N * from TABLE Order By Rnd(ID ......
void ModifyDBCode()
{
CString strPath;
::GetModuleFileName(GetModuleHandle(NULL),strPath.GetBuffer(256),256);
strPath.ReleaseBuffer();
int flag=strPath.ReverseFind('\\');
int size=strPath.GetLength();
strPath.Delete(flag,size-flag);
strPath= strPath+ ......
一、创建一张空表:
Sql="Create TABLE [表名]"
二、创建一张有字段的表:
Sql="Create TABLE [表名]([字段名1] MEMO NOT NULL, [字段名2] MEMO, [字段名3] COUNTER NOT NULL, [字段名4] DATETIME, [字段名5] TEXT(200), [字段名6] TEXT(200))
字段类型:
2 : "SmallInt", // 整型
3 : "Int", ......
最近系统运行中发现Access 2003 版本中对待 Null 和 ‘’ (空字符)奇怪问题,重现步骤:
1、创建表tabTest ;
2、使用设计视图添加两个字段 ID ,col1
名称
类型
长度
说明
ID
Number
主键,自增
Col1
char
1
无
3、使用sql 添加如下数据
-- col1 字段设置为 null
INS ......