关于Access和Excel的连接字符串
1.连接Access的连接字符串
string strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @FileName;
2.连接Excel
string strExcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + @FileName + ";Extended Properties=Excel 8.0;";
相关文档:
ASP.NET如何连接Access或SQL Server数据库
首先看一个例子代码片断:
程序代码:
--------------------------------------------------------------------------------
using System.Data;
using System.Data.OleDb;
......
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+ ......
新建表:
create table [表名]
(
[自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] datetime,
[字段4] money null ,
[字段5] int default 0,
[字段6] Decimal (12,4) default 0,
[字段7] image null ,
)
删除表:
Drop table [表 ......
一、创建一张空表:
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", ......
public static DataTable GetSchemaTable(string connectionString) //获取Access所有的表名;
{
using (OleDbConnection connection = new
&n ......
<?php
$connstr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("data.mdb");
$connid=odbc_connect($connstr,"","",SQL_CUR_USE_ODBC);
$issuetime=date("Y-m-d H:i:s");
$sql="insert into test values("","",...)";
$result=odbc_exec($connid,$sql);
if($result) echo "successful";
else ec ......