Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 如何在MS access VB中访问SQL Server标量函数_Sql Server_Sql Server 2005_Ms Access_Vba - Fatal编程技术网

Sql server 如何在MS access VB中访问SQL Server标量函数

Sql server 如何在MS access VB中访问SQL Server标量函数,sql-server,sql-server-2005,ms-access,vba,Sql Server,Sql Server 2005,Ms Access,Vba,我试图找出如何从adp文件的SQL Server数据库访问标量函数 我在access 2007中有一个adp文件和一个SQL Server 2005数据库 在accessvb中,我试图得到带有参数的标量函数的结果 我尝试使用DAO,但在这种情况下currentdb=nothing: Dim dbs As DAO.Database Dim sql2 As String Dim txt As String Dim iCount As Integer Set dbs = Curr

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

我在access 2007中有一个adp文件和一个SQL Server 2005数据库

在accessvb中,我试图得到带有参数的标量函数的结果

我尝试使用DAO,但在这种情况下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从未被设计为访问sql server,即使它是可能的

我相信CurrentDB属性是一个引用access数据库的DAO连接,可能无法与ADP一起使用,尽管我真的不知道,因为我从未使用过它们

ADO是您希望采用的方式

我还假设您坚持使用VBA,而不是使用.NET做任何事情


此外,您在主题中使用的术语“标量”具有误导性。Scalar意味着结果是一个值。CurrentDB从不为空,因为它总是返回一个新的数据库对象。但它与ADP无关,ADP不能使用Jet,必须使用ADO。DAO不能直接访问SQL Server,但肯定可以通过ODBC访问。