adodb

Are multiple JOINs unavailable when using ADODB to query an Excel file in a VBA procedure?

做~自己de王妃 提交于 2019-12-03 20:34:13
I have 3 sheets with data formatted as tables. The sheets names are "Riesgos", "Eventos" and "EventosRiesgos". EventosRiesgo has information relating events and risks (many to many relationship). I'm trying to get all the risks from Riesgos, but also the events related to the risks from (. I'm using ADODB to query the sheets as database tables and using the following SQL: SELECT * FROM [Riesgos$] r LEFT JOIN [EventosRiesgos$] er ON r.[Id]=er.[Id Riesgo] LEFT JOIN [Eventos$] e ON er.[Id Evento]=e.[Id] But i get an error, it's in Spanish but a rough translation would be: Syntax error (missing

How to populate a ComboBox with a Recordset using VBA

六月ゝ 毕业季﹏ 提交于 2019-12-03 12:56:51
There is some literature available at expert's exchange and at teck republic about using the combobox.recordset property to populate a combobox in an Access form. These controls are usually populated with a "SELECT *" string in the 'rowsource' properties of the control, referencing a table or query available on the client's side of the app. When I need to display server's side data in a combobox, I create a temporary local table and import requested records. This is time consuming, specially with large tables. Being able to use a recordset to populate a combobox control would allow the user to

Excel VBA - connect to sql with a trusted connection (no uid/pwd)

家住魔仙堡 提交于 2019-12-03 12:17:23
Is there a way to have Excel connect to Sql Server using the current user's network windows authentication (trusted connection/integrated security)? I don't want to rely on a sql login or have a uid/password in my code. I have this connectionstring in an Excel 2003 VBA project... "Provider=SQLOLEDB;Data Source=[You DB Name];Trusted_connection=yes;" And it works for me! (I'm using ADODB) Driver={SQL Native Client};server=servernamehere;database=dbnamehere;Trusted_Connection=yes; http://www.sqlstrings.com/SQL-Server-connection-strings.htm http://www.connectionstrings.com/sql-server Try this one:

Is it necessary to close an Adodb.recordset object before setting it to nothing?

穿精又带淫゛_ 提交于 2019-12-03 12:03:17
Dim rs as ADODB.Recordset set rs = ReturnARecordset 'assume ReturnARecordset does just that... 'do something with rs rs.Close set rs = Nothing Is it necessary to call rs.Close before setting it to nothing? Edit: We have one global connection that we keep open for the duration of the application and all recordset objects use this same connection. I see two answers below talking about the need to close recordsets in order to ensure connections aren't left hanging open. To me that sounds like a lot of silly talk because connections are controlled with connection objects, not recordset objects

“Invalid procedure call or argument” error on “New ADODB.Connection” only if compiled on Windows 7

你离开我真会死。 提交于 2019-12-03 08:09:50
I'm experiencing some problem when I compile some legacy apps on VB6 since I got a new development machine in windows 7. (my old one was on Windows XP.) If I compile the project on my XP machine, everything is fine. If I compile the same project on my Windows 7 machine, it still run fine one it, but if I try to run it on a XP machine, I got this error. Error Number : 5 Description : Invalid procedure call or argument Thanks to my error handler, I know that the line that throw this error is : Dim objConn As ADODB.Connection --> Set objConn = New ADODB.Connection I compared the references on

Read Registry Keys from within VBA using Windows Shell

こ雲淡風輕ζ 提交于 2019-12-02 15:21:57
问题 I have been searching around on the internet and am having problems finding a solution to this issue. Basically I am trying to execute a registry query with administrator privileges using Shell.Application from within VBA to read the value of TypeGuessRows (and eventually modify it to 0 aswell so that excel data can be correctly queried using ADOdb). I have come up with the following sub routine: Sub Read_Registry_Value() 'Declare variables Dim reg_key_location As String Dim reg_key_name As

Invalid SQL statement expected; ‘DELETE’,’INSERT’,

≡放荡痞女 提交于 2019-12-02 14:54:54
问题 I have a code Dim Cn As New ADODB.Connection Dim cmd As ADODB.Command Set cmd = New ADODB.Command Dim i As Long Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & ThisWorkbook.FullName & ";" & _ "Extended Properties=""Excel 8.0;""" Cn.Open cmd.ActiveConnection = Cn cmd.CommandText = "DECLARE @TS_HD DOUBLE;" & _ "SET @TS_HD = ?TS_HD;" & _ "SELECT So_HD, Ngay_HD, Ten_Khach_Hang, Ma_So_Thue, Sum(Doanh_So_KT) as DoanhSo, Sum(Thue_VAT) as VAT from [BR$] " & _ "Where

Using the same parameter twice

倾然丶 夕夏残阳落幕 提交于 2019-12-02 14:31:09
问题 I have the following SQL query: SELECT SUM(OpenInterest) *(SELECT DISTINCT Future FROM MTM WHERE Expiry = [dbo].fx_GetRelativeExpiry(@date, 1, @Code) and TradeDate = @date and Code = @Code and type = @Type and Class = 'Foreign Exchange Future') / 1000 FROM MTM WHERE Expiry = [dbo].fx_GetRelativeExpiry(@date, @N, @Code) and TradeDate = @date and Code = @Code and type = @Type and Class = 'Foreign Exchange Future' Which I want to use as a function in Excel. The issue is that I reuse parameters

Using the same parameter twice

坚强是说给别人听的谎言 提交于 2019-12-02 08:03:20
I have the following SQL query: SELECT SUM(OpenInterest) *(SELECT DISTINCT Future FROM MTM WHERE Expiry = [dbo].fx_GetRelativeExpiry(@date, 1, @Code) and TradeDate = @date and Code = @Code and type = @Type and Class = 'Foreign Exchange Future') / 1000 FROM MTM WHERE Expiry = [dbo].fx_GetRelativeExpiry(@date, @N, @Code) and TradeDate = @date and Code = @Code and type = @Type and Class = 'Foreign Exchange Future' Which I want to use as a function in Excel. The issue is that I reuse parameters many times in the above query and I don't know how to do that in excel without creating a new (and

PHP and ADODB connection fail

家住魔仙堡 提交于 2019-12-02 07:34:15
I have been tasked to migrate servers. This includes moving over apps I did not build, a couple of which have an ADODB.connection that I cannot seem to fix on the new servers (I only get blank screens). I have researched quite extensively ADODB.connection with PHP and cannot find a definite source. Most are related to VB Script, or even Excel documents. I even searched YouTube and the only thing I found wasn't even in English. I took some of the previous developer's code and created a test.php: <?php error_reporting(E_ALL); ini_set('display_errors', 1); // echo 'hello' <-- I can show this to