All Questions
Tagged with sql-server vba
1,529
questions
0
votes
0
answers
65
views
Why does this VBA code connecting to a SQL database return a syntax error?
This SQL query works perfectly in my Advanced Query Tool setup, but returns a Syntax Error when I plug it into the following SQL query:
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
...
0
votes
0
answers
59
views
VBA Excel to SQL Server table
I am inserting data from my Excel sheet to my SQL Server database table using VBA code.
All my table's columns are created as VARCHAR datatype. This is why I have added a alter table command in VBA ...
0
votes
0
answers
42
views
error using ADODB.Command with parameters [duplicate]
I am trying to INSERT a record into a Microsoft SQL Server table using an ADODB.Command object, from VBA.
I never used it before so I may be making stupid mistakes.
This is my code:
Sub Test_Insert()
...
0
votes
0
answers
38
views
Can I create a recordset using VBA that has a sp_executesql command? [duplicate]
I'm trying to build a SQL statement in VBA that I can run to generate a recordset.
The difficulty is that this is a complex statement that requires me to build a statement in SQL and then run it by ...
0
votes
1
answer
61
views
VBA macro works in local but not in SSMS SQL agent job
I want to run a VBA macro that create a folder then copy Excel file in this folder then modify them.
I run this macro perfectly on local (I press the "play" button in the macro editor). I ...
0
votes
0
answers
75
views
VBA MS Access bind ADO recordset to server side cursor
I am trying to bind ADO recordset from SQL Server to Form but cursor to be on server side. If I use adUseClient, working fine, but I can't find way to use adUseServer. Any help would be appreciated.
...
0
votes
0
answers
32
views
rs.parameters.append not executing in VBA to SQL Server code?
I have a script to send Excel table data (that matches the SQL Server ordering of headers and name) to a SQL Server. I keep getting this error:
Error executing SQL Statement: Wrong number of ...
0
votes
1
answer
81
views
How to add data of type "date from Excel sheet to SQL Server table
I have this code that can insert my Excel rows into a SQL Server table, but it doesn't work with the data of date type. In Excel, the data is 2010-02-21 but in the formula bar, it appears as 21/02/...
1
vote
0
answers
71
views
How to prevent Access from removing square brackets around a column name in a querydef?
I want to convert an Access database to SQL Server. For this, I use SQL Server Migration Assistent.
One of the problems I encounter is that one of my columns is called Current and it's accessed in a ...
0
votes
0
answers
96
views
WITH EXECUTE AS OWNER gives error to server admin
In my vba application my users can change their roles in SQL server database by invoking the following Stored Procedure:
ALTER PROCEDURE [dbo].[usp_chgRole]
@usr nvarchar(7), @db nvarchar(8), @...
0
votes
0
answers
113
views
Cannot connect to SQL Server after upgrade from SQL Server 2012 to SQL Server 2022 Visual Basic Application
I have a Visual Studio VB app that uses the string below to connect to SQL Server.
Dim strconnect As String = "data source=INFO-COR-SQL01;initial catalog=infocast;integrated security=true"
...
0
votes
0
answers
111
views
How to use VBA to export a table from MS access to SQL Server, but with a specific schema?
Say I have the following code in VBA
DoCmd.RunSQL "SELECT * INTO [ODBC;Driver={SQL Server};Server=EXAMPLESERVER;DATABASE=EXAMPLEDATABASE;Trusted_Connection=Yes].[test_import] FROM msaccess_table &...
0
votes
1
answer
134
views
How to get unique values from a filtered table through VBA?
I have a table that is being filtered through slicers which the user can fiddle around on their own. For example, say I have a table with 4 columns and after the user selects which filters he or she ...
0
votes
0
answers
296
views
How do I set the OLEDB connection string in VBA to query a SQL Server database with Always Encrypted columns?
I'm having trouble reading Always Encrypted data from SQL Server using ADO.
I have an Access front-end application which uses a SQL Server back-end. Some columns in the SQL Server database have been ...
0
votes
0
answers
76
views
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available
Excel VBA is throwing this error:
Multiple-step OLE DB Operation generated errors
on the line : conn.Open strConn
I'm trying to get an integer data from a table in SQL Server database. How do I ...