Skip to content

Commit e871604

Browse files
authored
Fix the casting error and EngineEdition error (#684)
* use GetValue and then typecast * fix copypaste error get the Edition
1 parent 4ba67b5 commit e871604

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/SqlBindingUtilities.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,15 @@ public static async Task<ServerProperties> GetServerTelemetryProperties(SqlConne
303303
{
304304
try
305305
{
306-
string serverPropertiesQuery = $"SELECT SERVERPROPERTY('EngineEdition'), SERVERPROPERTY('EngineEdition')";
306+
string serverPropertiesQuery = $"SELECT SERVERPROPERTY('EngineEdition'), SERVERPROPERTY('Edition')";
307307

308308
logger.LogDebugWithThreadId($"BEGIN GetServerTelemetryProperties Query={serverPropertiesQuery}");
309309
using (var selectServerEditionCommand = new SqlCommand(serverPropertiesQuery, connection))
310310
using (SqlDataReader reader = await selectServerEditionCommand.ExecuteReaderAsync(cancellationToken))
311311
{
312312
if (await reader.ReadAsync(cancellationToken))
313313
{
314-
int engineEdition = reader.GetByte(0);
314+
int engineEdition = reader.GetInt32(0);
315315
var serverProperties = new ServerProperties() { Edition = reader.GetString(1) };
316316
// Mapping information from
317317
// https://learn.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-ver16

0 commit comments

Comments
 (0)