如何访问SQL Server标量函数在MS Access VB [英] How to access SQL Server scalar functions in MS Access VB

查看:320
本文介绍了如何访问SQL Server标量函数在MS Access VB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何我可以从我的ADP文件的SQL Server数据库访问的标量函数。

我在进入2007年的ADP文件和一个SQL Server 2005数据库。

在获得VB我试图得到一个带参数的标量函数的结果。

我试着用DAO,但这种情况下,currentdb =什么:

 昏暗的星展银行作为DAO.DATABASE
  昏暗SQL2作为字符串
  昏暗的txt作为字符串
  昏暗ICOUNT作为整数

  设置DBS = CurrentDb
  TXT =SELECT * FROM dbo.TBL_Klanten'(tbl_klanten在mSQL的DB)
  dbs.Execute TXT,dbFailOnError
 

解决方案

DAO从来不是用于访问SQL Server,即使其可能的。

我相信CurrentDB属性是DAO连接引用Access数据库,并且可能无法与ADP的工作,即使我真的不知道,因为我从来没有使用过。

ADO是你想要去与此的方式。

我也假设你坚持使用VBA,而不是做任何与.NET。

ADO API参考

ADO对象参考

I'm trying to find out how I can access scalar functions from the SQL Server database of my adp file.

I have an adp file in access 2007 and a SQL Server 2005 DB.

In access VB I try to get the result of a scalar function with parameters.

I tried with DAO, but it that case currentdb = nothing:

  Dim dbs As DAO.Database
  Dim sql2 As String
  Dim txt As String
  Dim iCount As Integer

  Set dbs = CurrentDb
  txt = "SELECT * FROM dbo.TBL_Klanten" '(tbl_klanten is in the msql DB) '
  dbs.Execute txt, dbFailOnError

解决方案

DAO was never designed to access sql server even though its possible.

I believe the CurrentDB property is a DAO connection referencing the access database, and may not work with ADP, even though I don't really know since I've never used them.

ADO is the way you want to go with this.

I'm also assuming you're sticking with VBA rather than doing anything with .NET.

ADO API reference

ADO Objects reference

这篇关于如何访问SQL Server标量函数在MS Access VB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆