Skip to content

Commit

Permalink
Database: Windows OLEDB driver is not working (24.6) [STUD-64430]
Browse files Browse the repository at this point in the history
Remove SNI loading workaround (since dotnet runtime bug was fixed dotnet/runtime#16048)
Remove native SNI dlls from package
Fix buffer overruns when configuring Connect to Database activity using Connection Wizard
  • Loading branch information
viogroza committed Apr 10, 2024
1 parent f5552c5 commit a1e5af7
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ private void Build_Click(object sender, RoutedEventArgs e)
}

string currentConnectionString = _connectionProperties.ToFullString();
System.Text.StringBuilder newConnectionString = new System.Text.StringBuilder();
result = NativeMethods.SQLDriverConnect(hdbc, new WindowInteropHelper(Window.GetWindow(this)).Handle, currentConnectionString, (short)currentConnectionString.Length, newConnectionString, short.MaxValue, out short newConnectionStringLength, NativeMethods.SQL_DRIVER_PROMPT);
System.Text.StringBuilder newConnectionString = new System.Text.StringBuilder(short.MaxValue);
result = NativeMethods.SQLDriverConnect(hdbc, new WindowInteropHelper(Window.GetWindow(this)).Handle, currentConnectionString, (short)currentConnectionString.Length, newConnectionString, (short)newConnectionString.Capacity, out short newConnectionStringLength, NativeMethods.SQL_DRIVER_PROMPT);
if (!NativeMethods.SQL_SUCCEEDED(result) && result != NativeMethods.SQL_NO_DATA)
{
// Try again without the current connection string, in case it was invalid
result = NativeMethods.SQLDriverConnect(hdbc, new WindowInteropHelper(Window.GetWindow(this)).Handle, null, 0, newConnectionString, short.MaxValue, out newConnectionStringLength, NativeMethods.SQL_DRIVER_PROMPT);
result = NativeMethods.SQLDriverConnect(hdbc, new WindowInteropHelper(Window.GetWindow(this)).Handle, null, 0, newConnectionString, (short)newConnectionString.Capacity, out newConnectionStringLength, NativeMethods.SQL_DRIVER_PROMPT);
}
if (!NativeMethods.SQL_SUCCEEDED(result) && result != NativeMethods.SQL_NO_DATA)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using UiPath.Data.ConnectionUI.Dialog.Workaround;
using Res = UiPath.Data.ConnectionUI.Dialog.Properties;

namespace UiPath.Data.ConnectionUI.Dialog.Dialogs
Expand Down Expand Up @@ -98,7 +97,6 @@ internal IDataConnectionProperties ConnectionProperties
public DataConnectionSourceDialog()
{
InitializeComponent();
DbWorkarounds.SNILoadWorkaround();
DataConnectionConfiguration config = new DataConnectionConfiguration();
_dataSources = config.DataSources;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static string[] GetValueNamesWow64(string registryKey, int ulOptions)

for (uint index = 0; index < numValues; index++)
{
StringBuilder builder = new StringBuilder();
StringBuilder builder = new StringBuilder(short.MaxValue);
uint size = (uint)short.MaxValue;

try
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@
<BuildOutputInPackage Include="$(OutputPath)zh-CN\UiPath.Database.Activities.Design.resources.dll" TargetPath="zh-CN\UiPath.Database.Activities.Design.resources.dll" />
<BuildOutputInPackage Include="$(OutputPath)zh-TW\UiPath.Database.Activities.Design.resources.dll" TargetPath="zh-TW\UiPath.Database.Activities.Design.resources.dll" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<BuildOutputInPackage Include="$(OutputPath)runtimes\win-x86\native\Microsoft.Data.SqlClient.SNI.x86.dll" TargetPath="runtimes\win-x86\native\Microsoft.Data.SqlClient.SNI.x86.dll"/>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net461' ">
<BuildOutputInPackage Include="$(OutputPath)runtimes\win-x64\native\Microsoft.Data.SqlClient.SNI.dll" TargetPath="runtimes\win-x64\native\Microsoft.Data.SqlClient.SNI.dll" />
</ItemGroup>
</Target>
<Target Name="CleanPackageFiles" BeforeTargets="Build">
<Message Text="Deleting packages ..." />
Expand Down
2 changes: 0 additions & 2 deletions Activities/Database/UiPath.Database/DatabaseConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using System.Text;
using UiPath.Database.BulkOps;
using UiPath.Database.Properties;
using UiPath.Data.ConnectionUI.Dialog.Workaround;
using UiPath.Robot.Activities.Api;

namespace UiPath.Database
Expand All @@ -39,7 +38,6 @@ public DatabaseConnection()
#if NETCOREAPP
_isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#endif
DbWorkarounds.SNILoadWorkaround(_isWindows);
}

public DatabaseConnection Initialize(DbConnection connection)
Expand Down
15 changes: 0 additions & 15 deletions Activities/Database/UiPath.Database/UiPath.Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.1.0" />
<PackageReference Include="UiPath.Activities.Api" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<None Remove="runtimes\win-x64\native\Microsoft.Data.SqlClient.SNI.dll" />
<None Remove="runtimes\win-x86\native\Microsoft.Data.SqlClient.SNI.x86.dll" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\ConnectionDialog\UiPath.Data.ConnectionUI.Dialog\Workaround\DbWorkarounds.cs" Link="Workaround\DbWorkarounds.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="runtimes\win-x64\native\Microsoft.Data.SqlClient.SNI.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="runtimes\win-x86\native\Microsoft.Data.SqlClient.SNI.x86.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\UiPath.Database.Designer.cs">
<AutoGen>True</AutoGen>
Expand Down

0 comments on commit a1e5af7

Please sign in to comment.