Skip to content

Corrupt characters when reading NVARCHAR from SQL Server (SELECT @@VERSION) #12

@ccisnedev

Description

@ccisnedev

When running SELECT @@VERSION against SQL Server via an ODBC DSN, the returned NVARCHAR contains corrupt/garbage characters in Dart. The root cause appears to be that the binding does not perform incremental reads (SQLGetData in a loop) when the driver returns data in multiple parts.

Reproduction (minimal Dart):

import 'dart:io';
import 'package:dart_odbc/dart_odbc.dart';

Future<void> main() async {
	final dsn = Platform.environment['DSN'] ?? 'DSN';
	final user = Platform.environment['USERNAME'] ?? 'USERNAME';
	final pass = Platform.environment['PASSWORD'] ?? 'PASSWORD';

	final odbc = DartOdbc(dsn: dsn);
	await odbc.connect(username: user, password: pass);

	final rows = await odbc.execute('SELECT @@VERSION AS version');
	print(rows.isNotEmpty ? rows[0]['version'] : '<no rows>');

	await odbc.disconnect();
}

Expected: a clean, human-readable SQL Server version string (no binary/garbage bytes).

Observed: the printed string contains embedded garbage/non-printable bytes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions