用ODBC吧

有两种用法

一种是用ODBC API 这种不多说

另一种用ADO然后动态创建DSN,当然效率会比第一种低,但简单

动态创建DSN的例子:

程序代码:ODBC_CONFIG_DSN = 2 ' Configure (edit) data source

Private Const ODBC_REMOVE_DSN = 3 ' Remove data source

Private Const ODBC_ADD_DSN = 4

Private Const vbAPINull As Long = 0&

Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As Long, ByVal fRequest As Long, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Long

'Private Declare Function SQLCreateDataS

' ource Lib "ODBCCP32.DLL" (ByVal hwndPare

' nt As Long, ByVal lpszDriver As String)

' Api sql

Private Declare Function GetActiveWindow Lib "user32.dll" () As Long

Private Declare Function SQLAllocEnv Lib "ODBC32.DLL" (phenv&) As Integer

Private Declare Function SQLAllocConnect Lib "ODBC32.DLL" (ByVal henv&, hDBC&) As Integer

Private Declare Function SQLCreateDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As Long, ByVal lpszDriver As String)

Private Declare Function SQLDriverConnect Lib "ODBC32.DLL" (ByVal hDBC As Long, ByVal hwnd As Long, _

ByVal szCSIn As String, ByVal cbCSIn As Long, ByVal szCSOut As String, _

ByVal cbCSMax As Long, cbCSOut As Long, ByVal f As Long) As Long

Private Declare Function SQLAllocStmt Lib "ODBC32.DLL" (ByVal hDBC As Long, HStmt As Long) As Long

****************************************************

Public Function CreateDSN(ByVal pstrServer As String, ByVal pstrDescription As String, ByVal pstrDSN As String, ByVal pstrDataBase As String) As Long

On Error Resume Next

Dim strDriver As String

Dim strAttributes As String

'set the driver to SQL Server because it

' is most common.

strDriver = "SQL Server"'set the attributes delimited by null.

'See driver documentation for a complete

'list of supported attributes.

strAttributes = "SERVER=" & pstrServer & Chr(0)

strAttributes = strAttributes & "DESCRIPTION=" & pstrDescription & Chr(0)

strAttributes = strAttributes & "DSN=" & pstrDSN & Chr(0)

strAttributes = strAttributes & "DATABASE=" & pstrDataBase & Chr(0)

' strAttributes = strAttributes & "UID=u

' serid" & Chr$(0)

' strAttributes = strAttributes & "PWD=p

' assword" & Chr$(0)

strAttributes = strAttributes & "Trusted_Connection=Yes"

'Calls API to create DSN

CreateDSN = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver, strAttributes)

End Function

Public Sub DeleteDSN(sDSN As String)

Dim nRet As Long

Dim sDriver As String

Dim sAttributes As String

sDriver = "SQL Server"

sAttributes = sAttributes & "DSN=" & sDSN & Chr$(0)

nRet = SQLConfigDataSource(vbAPINull, ODBC_REMOVE_DSN, sDriver, sAttributes)

End Sub

Private Sub Command1_Click()

Dim lngRet As Long

Dim RetValue As Integer

RetValue = CreateDSN("Server", "DSN Server", "server", "master")

If RetValue = 0 Then

MsgBox Err.Description

Else

MsgBox "DSN Created!"

End If

End Sub

Private Sub Command2_Click()

'DeleteDSN "dsnTEst3"

Dim szConnectOut As String * 512

Dim Cadena As String

Dim Server As String

Dim stTmp As String

Dim User As String

Dim Cbout As Long

Dim lgTmp As Long

Dim henv As Long

Dim retcode As Long

' Lit le nom de l'utilisateur courant de

' l'ordinateur

stTmp = Space$(250)

lgTmp = 251

henv = 0

' Allocation de m閙oire pour un handle d

'environnement "HEnv".

If SQLAllocEnv(henv) = 0 Then

' Allocation d'un handle de connexion "H

' dbc".

If SQLAllocConnect(henv, hDBC) = 0 Then

' Etablir la connexion

' If you like you can specify a userId a

' nd Password and the database to be linke

' d the File DSN

'DATABASE=DB_CARTAS;UID=userid;PWD=passw

' ord

Cadena = "SAVEFILE=Testing_drv;DRIVER={SQL Server};FILEDSN=TEst_Drive;DSN=DB_PMR;SERVER=PMR02;Trusted_Connection=Yes"

retcode = SQLDriverConnect(hDBC, Me.hwnd, Cadena, Len(Cadena), szConnectOut, 255, Cbout, 1)

End If

End If

End Sub

Private Sub Command3_Click()

DeleteDSN "server"

MsgBox "DSN Remove!"

End Sub

[[it] 本帖最后由 三断笛 于 2008-12-10 22:32 编辑 [/it]]

php ado excel,求助::用ADO的方法修改EXCEL中单元格中的数据相关推荐

  1. excel统计求和:如何在合并后的单元格中复制求和公式

    如下图所示,左边表格,展示了每个物品品类的销售数据,现在,我们在表中新增一列合并单元格,需要根据行业将每个品类的明细销售额汇总,并展示在合并单元格中,如右边表格中,浅红色填充的部分所示. 注:以上数据 ...

  2. excel中单元格中同时显示日期和星期,填充句柄填充

    如上图所示的显示方式. 方法:右键单元格->设置单元格格式->自定义-> m"月"d"日"/[$-804]aaa 确定: 然后在当前单元格中输 ...

  3. Excel中单元格中空格的清除方法

    Excel表中有时会存在不小心录入了空格,造成数据比对出错,影响数据准确性,怎么来处理呢?有两张方法. 一.使用查找替换方法 1.打开查找/替换对话框 2.在"替换"框中的查找内容 ...

  4. java excel条件格式_Java 设置Excel条件格式(高亮条件值、应用单元格值/公式/数据条等类型)...

    概述 在Excel中,应用条件格式功能可以在很大程度上改进表格的设计和可读性,用户可以指定单个或者多个单元格区域应用一种或者多种条件格式.本篇文章,将通过Java程序示例介绍条件格式的设置方法,设置条 ...

  5. 使用Python提取Excel中单元格中的某一段内容(包含某特定字符且前后以逗号作为分隔符的内容)

    需求描述 提取红色方框的内容 思路 先找到乘号"x",将整个字符串分成ab两部分: 在a部分寻找最后一个逗号的位置,记录这个位置: 取a位于该位置右边的内容,记为s1: 在b部分寻 ...

  6. html合并单元格怎么把字竖着,电脑excel单元格中文字如何在合并单元格后竖排显示...

    电脑excel单元格中文字如何在合并单元格后竖排显示 excel软件是我们现在经常使用的数据处理工具之一,接下来小编就教大家怎样在软件中设置合并单元格之后竖排显示文字. 具体如下: 1. 首先我们需要 ...

  7. 在单元格中进行Excel换行的两种方法和取消换行符的方法

    我想打破Excel中的字符串! 如何破坏单元格中的字符串? 如果要将输入的文本换行到Excel单元格,有时会看到键入大量空间并强行提供行的情况,但效率非常低.让我们来看看如何做一个整洁的细胞休息. 如 ...

  8. EXCEL中将多个单元格内容合并到一个单元格中的方法(转帖+亲自实践)

    原帖位置:EXCEL中将多个单元格内容合并到一个单元格中的方法 http://t.excelhome.net/thread-3875-1-1.html 说明:这个技巧主要用到以下2个功能 1.Offi ...

  9. 使用C#和Excel进行报表开发(四)-复制单元格 【转】

    在用Excel作报表的时候,可能会碰到分页的情况,这样就要分成多个Sheet显示,如果要在每页都保留表头,就需要将第一页作为模板设计的表头部分拷贝到其他的Sheet上,这时就要用用到Excel中的单元 ...

最新文章

  1. sqlserver 指数_指数基金的分类有哪些?
  2. 【SpringBoot专题】监控健康状况
  3. vs2010 qt中文乱码 最终版
  4. echarts symbol 回调函数_凹函数和凸函数到底什么样?傻傻分不清楚
  5. PHP的simplexml_load_file
  6. mybatis_user_guide(7) SQL语句构建器类
  7. java jsonobject_Java实现QQ登录
  8. python抓取教学_Python Selenium 实战教学:爬取每日天气
  9. wpf 让图标显示在系统托盘
  10. 史上最简SLAM零基础解读(4) - 单应性Homography →公式推导与细节理解
  11. Redis学习之hget命令
  12. LeetCode之数组中的最长山脉
  13. 深度自定义macOS邮件程序的个性签名内容
  14. 两轮电动车越来越拥挤了
  15. ATM (Asynchronous Transfer Mode)异步传输模式
  16. win10在此计算机上找不到系统映像,图文教你win10系统使用DISM修复找不到源的问题....
  17. centos下安装PhpMyAdmin
  18. Cesium 通过scaleByDistance设置远小近大的广告牌图形视觉效果
  19. 五格数理用字(笔画+五行)
  20. 如何找到msdn中文文档呢?

热门文章

  1. 关于使用jquery.wordexport.js如何设置导入文档的页边距问题(超详细,亲测可用)
  2. 数据分析tableau 和 python的区别_FineBI和Tableau深度对比
  3. Tableau导出sql语句和性能监控
  4. macOS下载的文件执行出现operation not permitted问题
  5. unity点击UI防止触碰UI后面物体
  6. 使用Keil虚拟仿真逻辑仪和真实逻辑仪(SaleaeLogic16)
  7. OC下的串行、并行和同步、异步的组合
  8. python3学习(6):ID 遍历爬虫,将需要下载的网页数量最小化
  9. Abusing UIViewControllers
  10. 甘肃省基础地理信息数据大全(shp格式)下载地址