Power bi error 2147467259

If you try to use a Microsoft Jet (Access) database from multiple instances of the same application either on the same computer or on different computers, you receive the following error message:

Symptoms

If you try to use a Microsoft Jet (Access) database from multiple instances of the same application either on the same computer or on different computers, you receive the following error message:

-2147467259 Error ODBC Microsoft Access Driver: The database has been placed in a state by an unknown user that prevents it from being opened or locked.

This error occurs with both the Microsoft ODBC Driver for Access and the OLE DB Provider for Jet.

Cause

To run an .mdb file by multiple instances, Jet makes use of a lock delay and retry interval. However, under high load conditions, you may exceed these intervals.

Resolution

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners — https://partner.microsoft.com/global/30000104

Microsoft Advisory Services — http://support.microsoft.com/gp/advisoryservice

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMSThe following workaround extends the retry delay for Jet so that you can use additional instances. However, it is not recommended that you use this workaround if a high number of updates are being formed; this workaround is intended only for reading databases.

You can add the following sample error handler to your code. Please note that this handler only works with ADO and uses the Sleep function, which you must declare in your general declarations section.

RetryHandler:
' Retry until MAX_RETRIES are hit to increment your error count.
errorcount = errorcount + 1
If errorcount < MAX_RETRIES Then

' Sleep a random amount of time, and retry the same operation.
Sleep Int(MAX_SLEEP_INTERVAL * Rnd) + 1
Resume
Else
' Retries did not help. Show the error, and fall out.
MsgBox Err.Number & " " & Err.Description
Exit Sub
End If

Status

This behavior is by design.

More Information

The above-mentioned workaround is only for read-only mode. Microsoft does not support placing Jet .mdb files under high user load. Microsoft strongly recommends that you use Microsoft SQL Server or Microsoft Data Engine (MSDE) instead of Access when high user loads (that is, more than 15 instances) are required or anticipated, especially when updating is required.

References

For more information about the Sleep function, refer to the MSDN Library documentation.

Need more help?

Содержание

  1. PRB: Error -2147467259 When You Try to Open the Same MDB File from Multiple Instances
  2. Symptoms
  3. Cause
  4. Resolution
  5. Status
  6. More Information
  7. References
  8. Error on running Python script on Power BI—ErrorCode=-2147467259 #1495
  9. Comments
  10. Document Details
  11. Power bi error 2147467259
  12. Error on running Python script on Power BI—ErrorCode=-2147467259 #1495
  13. Comments
  14. Document Details

PRB: Error -2147467259 When You Try to Open the Same MDB File from Multiple Instances

Symptoms

If you try to use a Microsoft Jet (Access) database from multiple instances of the same application either on the same computer or on different computers, you receive the following error message:

-2147467259 Error ODBC Microsoft Access Driver: The database has been placed in a state by an unknown user that prevents it from being opened or locked.

This error occurs with both the Microsoft ODBC Driver for Access and the OLE DB Provider for Jet.

Cause

To run an .mdb file by multiple instances, Jet makes use of a lock delay and retry interval. However, under high load conditions, you may exceed these intervals.

Resolution

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMSThe following workaround extends the retry delay for Jet so that you can use additional instances. However, it is not recommended that you use this workaround if a high number of updates are being formed; this workaround is intended only for reading databases.

You can add the following sample error handler to your code. Please note that this handler only works with ADO and uses the Sleep function, which you must declare in your general declarations section.

Status

This behavior is by design.

More Information

The above-mentioned workaround is only for read-only mode. Microsoft does not support placing Jet .mdb files under high user load. Microsoft strongly recommends that you use Microsoft SQL Server or Microsoft Data Engine (MSDE) instead of Access when high user loads (that is, more than 15 instances) are required or anticipated, especially when updating is required.

References

For more information about the Sleep function, refer to the MSDN Library documentation.

Источник

Error on running Python script on Power BI—ErrorCode=-2147467259 #1495

Hi team,
I’m moving this here https://github.com/MicrosoftDocs/powerbi-docs.zh-cn/issues/42
because it may be related with the original documentation

@linxurong commented 8 days ago — with docs.microsoft.com
I found a error most of time when I run a python script on Power BI, how to solve this issue

DataSource.Error: ADO.NET: A problem occurred while processing your Python script.
Here are the technical details: Process must exit before requested information can be determined.
Details:
DataSourceKind=Python
DataSourcePath=Python
Message=A problem occurred while processing your Python script.
Here are the technical details: Process must exit before requested information can be determined.
ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.Python.Exceptions.PythonUnexpectedException

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

  • ID: 070da3e8-5146-a2ca-9ac3-ed77621fc050
  • Version Independent ID: 2dcfbb4b-3661-50bb-43b7-050aa77e710d
  • Content: Run Python Scripts in Power BI Desktop — Power BI
  • Content Source: powerbi-docs/desktop-python-scripts.md
  • Service: powerbi
  • Sub-service: powerbi-desktop
  • GitHub Login: @otarb
  • Microsoft Alias: otarb

The text was updated successfully, but these errors were encountered:

Источник

Power bi error 2147467259

I have a report which I’ve published to the cloud. Got the gateway set up, everything seemed to be working and managed to refresh a couple of times.

Unfortunately, I can no longer refresh the report in the Cloud due to the error:
‘Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.’

I am perfectly able to refresh the report in the desktop from the same data sources and I have double checked the original data source and the only field on the one side of a one to many relationship is perfectly unique.

The data source is an AWS MySQL server for which a gateway is set up and working (I can refresh other models from the same source).

I do not understand why this issue occurs and why it occurs only in the cloud and not in my desktop, any help would be greatly appreciated.

Please correct me if I wrongly your issue .

Your data source is MySQL server and it is hosted on AWS . You created a report in Desktop and you can refresh data successfully in Desktop . Then you published the report to Service and refreshed the report in Service , but it failed , right ?

In this case , can you make sure that the gateway can connect to your data source successfully ? As we all know , that the Desktop can refresh data without gateway , but Service is not . If it is possible , can you explain what did you do to refresh on the Service?

Best Regards,
Community Support Team _ Ailsa Tao

  • Mark as Read
  • Mark as New
  • Bookmark
  • Permalink
  • Print
  • Report Inappropriate Content

Is AWS MySQL server local ? You mentioned you published the report to cloud , how can you get the report that stored in cloud ?

Best Regards,
Community Support Team _ Ailsa Tao

  • Mark as Read
  • Mark as New
  • Bookmark
  • Permalink
  • Print
  • Report Inappropriate Content

Thank you for getting back to me. The MySQL server is hosted on AWS, there is a gateway connection to the AWS Virtual Private Network which is able to access to the Databases on MySQL.

I’m not sure I understand your second question, maybe I was misleading when I said the cloud. I published the Power BI Report containing the data model to Power BI.com (what I meant by the cloud), from here I am now trying to refresh the data model.

It is clearly able to find the MySQL server and the tables needed to refresh the data as the error is on constraints. It seems to think one of the tables has a non unique field which should be unique. My issue is that, the field in question is very much unique and I’m able to refresh the exact same data model in Power BI desktop without any such issues. Very confusing!

Thank you very much for getting back to me
WG

Источник

Error on running Python script on Power BI—ErrorCode=-2147467259 #1495

Hi team,
I’m moving this here https://github.com/MicrosoftDocs/powerbi-docs.zh-cn/issues/42
because it may be related with the original documentation

@linxurong commented 8 days ago — with docs.microsoft.com
I found a error most of time when I run a python script on Power BI, how to solve this issue

DataSource.Error: ADO.NET: A problem occurred while processing your Python script.
Here are the technical details: Process must exit before requested information can be determined.
Details:
DataSourceKind=Python
DataSourcePath=Python
Message=A problem occurred while processing your Python script.
Here are the technical details: Process must exit before requested information can be determined.
ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.Python.Exceptions.PythonUnexpectedException

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

  • ID: 070da3e8-5146-a2ca-9ac3-ed77621fc050
  • Version Independent ID: 2dcfbb4b-3661-50bb-43b7-050aa77e710d
  • Content: Run Python Scripts in Power BI Desktop — Power BI
  • Content Source: powerbi-docs/desktop-python-scripts.md
  • Service: powerbi
  • Sub-service: powerbi-desktop
  • GitHub Login: @otarb
  • Microsoft Alias: otarb

The text was updated successfully, but these errors were encountered:

Источник

Please login or click SIGN UP FOR FREE to create your PowerBIUG account to join this user group.

Dataset Refresh Failure

  • 1. 
    Dataset Refresh Failure

    Posted Nov 30, 2018 02:40 PM

    ​My Power BI report data set refresh fails. I have copied below the error msg. Does anyone has similar issue? and also appreciate your comments, input and any resolutions.

    Last refresh failed: Fri Nov 30 2018 10:16:15 GMT-0800 (Pacific Standard Time)
    Cannot connect to the mashup data source. See error details for more information.Hide details
    Underlying error code: -2147467259 Table: Invoice Totals by Cust and Product.
    Underlying error message: MySQL: Fatal error encountered during data read.
    DM_ErrorDetailNameCode_UnderlyingHResult: -2147467259
    Microsoft.Data.Mashup.ValueError.DataSourceKind: MySql
    Microsoft.Data.Mashup.ValueError.DataSourcePath: 00.00.00.000;xxyyss
    Microsoft.Data.Mashup.ValueError.ErrorCode: -2147467259
    Microsoft.Data.Mashup.ValueError.Message: Fatal error encountered during data read.
    Microsoft.Data.Mashup.ValueError.Reason: DataSource.Error

    ——————————
    Brian Gunns
    97477
    ofd
    SPRINGFIELD OR
    ——————————

  • 2. 
    RE: Dataset Refresh Failure

    Posted Dec 03, 2018 08:09 AM

    ​Its just from my own experience of this error, but its probably either credentials in the Gateway being out of date (password expired?), the credentials don’t allow access to one or more data sources (account locked?) or possibly that there is a data source the Gateway can no longer access (changed file location, permissions etc.).

    ——————————
    Simon Hill
    Manager
    TTX Company
    Solihull
    ——————————

  • 3. 
    RE: Dataset Refresh Failure

    Posted Dec 04, 2018 08:47 AM

    Definitely not a permission issue.  It throws various errors regarding the query and the underlying data.
    It turned out if I pushed the filter after the first merge (where it couldn’t convert the table to a table) it worked while still being part of the native query.  All subsequent merge efforts do not use query folding for various reasons.  In any case once I figured out the best «order of steps» in Power Query it now loads.  Albeit ridiculously slow, but it loads.  Ideally, I would prefer to just use a custom query on this one and pass in the IN clause as a parameter (Value.NativeQuery) or using string concatenation prior to using it.  This method works fine in desktop, but fails on the server having nothing to do with credentials.

    ——————————
    Daniel Davis
    Business Intelligence Developer
    TPX Communications
    Portland, ME
    ——————————

  • 4. 
    RE: Dataset Refresh Failure

    Posted Feb 16, 2021 05:36 AM

    Hello Daniel

    Found your posting this morning. I half understand your workaround. When you get a moment, appreciate your unpacking ‘ pushed the filter after the first merge’.

    Thanks

    John

    ——————————
    John Martin
    ——————————

Resolved : Power BI Report connection error during execution

Getting Below Power BI Report connection error during execution .

Error:

Something went wrong

Unable to connect to the data source undefined.

Please try again later or contact support. If you contact
support, please provide these details.

Underlying error code: -2147467259 Table: Business
Sector.

Underlying error message: AnalysisServices: A connection
cannot be made. Ensure that the server is running.

DM_ErrorDetailNameCode_UnderlyingHResult: -2147467259

Microsoft.Data.Mashup.ValueError.DataSourceKind:
AnalysisServices

Microsoft.Data.Mashup.ValueError.DataSourcePath:
10.10.10.60;T_CustomerMaster_ST

Microsoft.Data.Mashup.ValueError.Reason: DataSource.Error

Cluster URI:
WABI-WEST-EUROPE-redirect.analysis.windows.net

Activity ID: c72c4f12-8c27-475f-b576-a539dd81826a

Request ID: dfb54166-c78f-4b40-779f-e8922a6687ad

Time: 2019-09-26 10:03:29Z

Solution:

We found report connection not able to connect to SQL Analysis service so tried below option.

Restart SQL Analysis service.

Refresh SQL Analysis database

Connect in SQL Management studio success

Then refresh report connection at Power BI Side

Error resolved.

Popular posts from this blog

1. Which of the following queries can you use to search for employees with the pattern ‘A_B’ in their names? A. SELECT last_name FROM employees WHERE last_name LIKE ‘%A_B%’ ESCAPE ‘\’; B. SELECT last_name FROM employees WHERE last_name LIKE ‘%A_B%’ ESCAPE; C. SELECT last_name FROM employees WHERE last_name LIKE ‘A_B%’ ESCAPE ‘%’; D. SELECT last_name FROM employees WHERE last_name LIKE ‘%A_B%’ ESCAPE »; 2. The number of records in a table emp is given by statement A. Select total(*) from emp; B. Select count(*) from emp; C. Select sum(*) from emp; D. Select total from emp; 3. Write a query to Display the Name and studentid of all Students of branch CSE and ECE in alphabetical order by name. 4. Can you use the SQL JOIN and SQL HAVING clauses in one SQL statement? A .Yes. B . No. C . It depends. D . Don’t know 5. # Which four are valid Oracle constraint types? A.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
Option Compare Database
Option Explicit
 
'--------------------------------------------------------------------------
' Module    : modLink_MySQL_ADOX
' Author    : es
' Date      : 24.07.2017
' Purpose   : Переподключение таблиц MySQL без DSN
'--------------------------------------------------------------------------
' - Требует установки MySQL ODBC ODBC MySQL драйвера
'--------------------------------------------------------------------------
'Требуются ссылки на:
'    Microsoft ADO Ext. for DDL and Security. (Version 2.1 or higher)
'    Microsoft ActiveX Data Objects Library. (Version 2.1 or higher)
'--------------------------------------------------------------------------
 
 
Public ConnStr$
Private cat As ADOX.Catalog
Private tbl As ADOX.Table
Private AConnectionString_ADOX As String
Private i%, s$
 
Public Sub StartReLink_MySQL_ADOX(Optional bDelOnly As Boolean)
'Собственно процедура подключения (основная)
 
Dim arrTables() As Variant
Dim arrTables_1() As Variant
 
'--------------------------------------------------------------------------
On Error GoTo StartReLink_MySQL_ADOX_Err
    DoCmd.Hourglass True 'Показать часики
 
 
'Массив табличек:
    arrTables = Array("Amper", "Baza", "Baza_Pitatel", "Cat_Empl", "Chet", "Chet_Kompl", "Cklad", "Vid_Nomenkl_ERP", "Klaccif_Nomenkl_ERP", "Uroven_Ctrykt_ERP", _
        "Cklad_Dvig_Izd", "Cod_Empl", "Cotrydnik", "Cpecifikaciy", "Cpecifikaciy_Pza1", "Cpr_Nomenkl_ERP", "Ctryktyra_Izdely_ERP", _
        "Cpocob_Per_Zak", "Cpr_Dorabotok", "Ctr_Izd_Modyl", "Ctr_Izd_Ocnov", "Ctrana", "Licev_Nakl_Izdelie", "Licev_Nakl_Plan_Vipycka_Izd", "Licev_Nakl_Prixod", "Licev_Nakl_Racxod", "Izdelie_Licev", _
        "Ctryktyra_Izdely", "Cvoictva_Znach", "Cvoictvo_Detali", "Dolznoct", "Dop_Zamena", "Operacii_ERP", "Izdely_Operacii_ERP", _
        "Edinicy_Izmereny", "Forma_Cobctv", "Funk_Claim", "Funk_Otvetctv_Za_Vip", _
        "Funk_Pol_Inform", "Funk_Procecc", "Funk_Structure", "Funk_View", "Funk_Ychactv_V_Vip", _
        "Gorod", "Grup_Empl", "Gryp_Clozn_Rem", "Icpolnenie", "Identifikator_Izd", _
        "Invent_Cklad", "Izdelie", "Izdelie_copy", "Izdelie_Komplekty", "Izd_Preemnik", "Izdelie_Modifikaciy", "Izdelie_TO", _
        "Izdely_Gryp", "Izv_Cogl", "Izv_Cogl_Jyrnal_Cob", "Izv_Ctatyc", "Izv_Formylirovki", _
        "Izv_Izdelie", "Izv_Jyrnal_Cob", "Izv_Koment", "Izv_Koment_Jyrnal_Cob", "Izv_Modul", "Izv_Kritichnoct", _
        "Izv_Vid_Cogl", "Izveshenie", "Level_Competence", "Mecto_Xraneniy", "Modifikaciy", _
        "Modyl", "Name_Funk", "Name_Group", "NameFunk", "Necootvetctv", "Oboryd_TO", _
        "Oborydovanie", "Ogr_Cpicok", "ooDecim_Nomer", "ooGryppa_Izd", "ooKlacc_Izd", _
        "ooPodgryppa_Izd", "ooPodklacc_Izd", "ooPor_Regictr_Nomer", "ooVid_Izd", "Operaciy_Cklad", _
        "Operaciy_Oboryd", "Operaciy_Texnol", "Operaciy_Vipol", "Opicanie_Cvoictv", "Org_Ctrykt", _
        "Organizat_Role", "Otdel", "Pitatel", "Bab_Fid_Yct", "Fider", "Fider_Kompon_Progr", "Fider_Pit", _
        "Racpolozenie", "Pitatel_Partia", "Pitatel_Xarakter", "Plata_Defekt", "Poctavchik", _
        "Porycheniy", "Prichina_Vozvr_Iz_OTK", "Privyzka_Coctava", "Process", "Process_A", "Progr", "TP_Mex", "TP_Mex_Vibor", "TP_Mex_Vipoln", "Partiy_Mex", "Peremesh_Mex", _
        "Proizvod", "R_RA", "Rabota_Robotov", "Requ_For_Specialty", "Site", "Sites_1", "Texprocecc", _
        "Tip_Dokym", "Tip_Operaciy", "To_I_R", "To_I_R_Prichina", "To_I_R_Cherez_Cklad", "To_I_R_Cherez_Cklad_copy", "Obmenniy_Fond", "To_Izd", "Imiy_Shkafa", "To_Izd_Cpicok_Rab", _
        "To_Obor_Cpicok_Rab", "Verciy_PO", "Verciy_Po_Aktualn", "Vid_Rabot", "Vid_Rabot_To", _
        "Vizm_Neicpr_Napominal", "Vozm_Neicpr_Priborov", "Volt", "Vozvrat_Iz_Otk", "Vxod_Kontrol", "Zakaz", "Zakazchik", "Bx_Kontr_Nomenkl", "Bx_Kontr_Zyrnal", "Cootvetctvie", _
        "Zip", "Zip_Cklad", "Zip_Cklad_Racxod", "Zip_Dvigenie", "Zip_Imia", "Zip_Mex_Cbor", "Klacter_Remonta", "Klacter_Remonta_Org", _
        "Zip_Partiy", "Zip_Partiy_Brem_Nakleika", "Zip_Poctavshik", "Zip_Vid", "Zip_Ynikaln", "Izdelie_Verciy_PO", "Dokyment", _
        "Imenovanie", "Klassif_Schtrix", "Texprocecc_Izd", "Klaccif_Nomer_PO", "Reviziy_PO", "Tip_Failov_PO", "Remont", "Kod_1_Panel_IHM", "Kod_2_Panel_IHM", "Kod_3_Panel_IHM", "Kod_4_Panel_IHM", "Kod_Coctav_Modyley_VV", "Kod_Tip_Mezonina_Cviazi", "Kod_Tip_Modyl_Proceccora", "Kod_Tip_Razmeri_Korpyca", "Kod_Vercii_PO", "Ciriyc_New", "Ciriyc_New_Racborka")
    'arrTables = Array("Uroven_Ctrykt_ERP", "Cpr_Nomenkl_ERP", "Ctryktyra_Izdely_ERP", "Operacii_ERP", "Izdely_Operacii_ERP")
 
'--------------------------------------------------------------------------
'Предварительный промсмотр (если нужно):
    Debug.Print String(74, "-")
    For i = LBound(arrTables) To UBound(arrTables)
        s = arrTables(i)
        Debug.Print Format(i + 1, "000"); ".  " & s
    Next i
    Debug.Print String(74, "-")
    Debug.Print "Всего: " & Format(i, "00") & " таблиц " & Now
    Debug.Print String(74, "-")
'--------------------------------------------------------------------------
    'GoTo StartReLink_MySQL_ADOX_Bye
    
'Запуск
    'ReLinkTables_ADOX arrTables, "00_", bDelOnly    ' Полное переподключение
    ReLinkTables_ADOX arrTables, , bDelOnly    ' Полное пере-подключение
 
StartReLink_MySQL_ADOX_Bye:
    DoCmd.Hourglass False 'Вернуть нормальный курсор
    Exit Sub
 
StartReLink_MySQL_ADOX_Err:
    MsgBox "Error: " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
    "in procedure: StartReLink_MySQL_ADOX in module: modLink_MySQL_ADOX", _
    vbCritical, "Error in Application!": Err.Clear
    Resume StartReLink_MySQL_ADOX_Bye
        
End Sub
 
Private Sub ReLinkTables_ADOX(arrTables() As Variant, Optional sTblLocalPrefix$ = "", Optional bDelOnly As Boolean)
' Вспомогательная -  Переподключение таблиц по массиву
'--------------------------------------------------------------------------
'Аргументы:
'   arrTables()      = Массив табличек
'   sTblLocalPrefix  = Локальный префикс названий
'   bDelONly         = Только удалить и не подключать если = True (-1)
'--------------------------------------------------------------------------
Dim sTblName$
Dim sDriver As String
Dim sServerAdr As String
Dim sCharset As String
Dim sServPort As String
Dim sDbName As String
Dim sUser As String
Dim sPassWord As String
Dim l&
 
On Error GoTo ReLinkTables_ADOX_Err
 
    
    If Dir("C:Program FilesMySQLConnector ODBC 3.51", vbDirectory) <> "" Then
        sDriver = "{MySQL ODBC 3.51 Driver}" 'Папка Connector ODBC 3.51 существует. Драйвер для 32 разрядной операционной системы(для устаревших компьютеров- где дополниетльные программы (требующиеся для работы этого драйвера) плохо или не ставятся вовобще)
    ElseIf Dir("C:Program FilesMySQLConnector ODBC 5.3", vbDirectory) <> "" Then
        sDriver = "{MySQL ODBC 5.3 Unicode Driver}" 'Драйвер для 32 или драйвер для 64 разрядного MS Office - в зависимости , что установлено. Имя папки одинаковое.
    Else
        MsgBox "Нет драйвера ODBC для работы с  MySQL"
        Exit Sub
    End If
    
    'sServerAdr = "localhost"
    sServerAdr = "managementdb.rza.ru"   ' Адрес (Имя) сервера
    sServPort = "3306"         ' Порт соединения = 3306 (Обычно так и есть)
    sDbName = "management" ' Название базы
    sUser = "management"             ' Имя пользователя
    sPassWord = "123456"    ' Пароль
 
s = ""
'Создаю строку подключения:
 ConnStr = ";DRIVER=" & sDriver & _
        ";SERVER=" & sServerAdr & _
        ";Port=" & sServPort & _
        ";DATABASE=" & sDbName & _
        ";USER=" & sUser & _
        ";PASSWORD=" & sPassWord & _
        ";OPTION=3" & _
        ";stmt=set names cp1251"
        Debug.Print ConnStr
        Debug.Print String(74, "-")
    
    
'Строим строку подключения ... - добавляем "ODBC;" в начало уже готовой (см выше)
    AConnectionString_ADOX = "ODBC;" & ConnStr
 
'Катплог
    Set cat = New ADOX.Catalog
    'Открываем каталог текущей базы
    Set cat.ActiveConnection = CurrentProject.Connection
 
'Удаление всех таблиц по именам
     For i = LBound(arrTables) To UBound(arrTables)
        sTblName = arrTables(i)
        s = sTblLocalPrefix & sTblName
        DelTable_ADOX s
    Next i
    cat.Tables.Refresh
    Debug.Print String(74, "-")
 
    If bDelOnly = True Then GoTo ReLinkTables_ADOX_Bye
'Подключение  всех по именам
    For i = LBound(arrTables) To UBound(arrTables)
        sTblName = arrTables(i)
        'Debug.Print Format(i, "000") & " - " & sTblName
        LinkTable_ADOX sTblName, AConnectionString_ADOX, sTblLocalPrefix & sTblName
    Next i
    
'Отчёт о проделанной работе
    'Debug.Print String(74, "-")
    Debug.Print "Подключено: " & Format(i, "000") & " таблиц " & Now
    Debug.Print String(74, "-")
 
    
ReLinkTables_ADOX_Bye:
    On Error Resume Next
    'Обновляем список таблиц
    cat.Tables.Refresh
    
    cat.ActiveConnection.Close
    Set cat = Nothing
    Set tbl = Nothing
    
    'Keep_ADO_Connection
    Exit Sub 'Ура!!!
 
ReLinkTables_ADOX_Err:
    s = "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
    "In procedure: ReLinkTables_ADOX in module: modCommon_ADOX"
    Debug.Print s
    MsgBox s, vbCritical, "Error in Application!"
    Err.Clear
    Resume ReLinkTables_ADOX_Bye
End Sub
Private Sub DelTable_ADOX(s$)
'Удаление подлинковки.
    On Error Resume Next
    cat.Tables.Delete s
    If Err = 0 Then Debug.Print s & " ... Deleted!"
    Err.Clear
End Sub
 
Private Sub LinkTable_ADOX(stRemTName As String, strConnect As String, Optional strLocalTableName As String = "")
'es 08.05.2017
'Подлинковка таблички MySQL Server с автоматическим созданием DSN (ADOX)
'Использует общие переменные данного модуля (так короче и возможно быстрее)
'-------------------------------------------------------------------------
'Аргументы:
'   stRemTName  = Имя таблицы на сервере
'   strConnect  = Строка подключения к серверу с "ODBC:DRIVER = ..."
'   strLocalTableName = Локальное Имя Таблицы
'-------------------------------------------------------------------------
 
On Err GoTo LinkTable_ADOX_Err
'Если локальное имя не указанно
    If strLocalTableName = "" Then strLocalTableName = stRemTName
    
     Set tbl = New ADOX.Table
 
'Установка параметров таблицы
    With tbl
        .Name = strLocalTableName
        Set .ParentCatalog = cat
        .Properties("Jet OLEDB:Link Provider String") = strConnect
        .Properties("Jet OLEDB:Remote Table Name") = stRemTName
        .Properties("Jet OLEDB:Create Link") = True
    End With
    
'Создаём новый обьект
    cat.Tables.Append tbl
    'cat.Tables.Refresh
    
LinkTable_ADOX_Bye:
    Exit Sub
 
LinkTable_ADOX_Err:
    'LinkTable_ADOX = Err.Number
    Debug.Print "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
            "in Function: esLinkTable_ADOX"
    Resume LinkTable_ADOX_Bye
End Sub

Понравилась статья? Поделить с друзьями:
  • Postgresql error codes
  • Postgresql error binding the test network socket 10013
  • Postgresql error a column definition list is required for functions returning record
  • Postgresql error 53300
  • Power alpha error