Skip to content

SqlCommandBuilder.DeriveParameters to Sql2005 Database #1777

@DanielVinagre

Description

@DanielVinagre

Describe the bug

With a connection to a SQL Server 2005 Database, SqlCommandBuilder.DeriveParameters is creating Parameters of SqlDbType.Variant when the parameter is of type Int

To reproduce

string connString = @"Server=SQL2005_INSTANCE;Database=DB_NAME;UID=sa;Password=YOUR_PASSWORD;TrustServerCertificate=True;";
Microsoft.Data.SqlClient.SqlConnection conn = new Microsoft.Data.SqlClient.SqlConnection(connString);
conn.Open();

Microsoft.Data.SqlClient.SqlCommand command = new Microsoft.Data.SqlClient.SqlCommand("STORED_PROC_NAME", conn);
command.CommandType = CommandType.StoredProcedure;
Microsoft.Data.SqlClient.SqlCommandBuilder.DeriveParameters(command);
conn.Close();

SqlDbType dbtype = command.Parameters[1].SqlDbType;

Expected behavior

Parameters Type be of the right type according to the procedure

Further technical details

Microsoft.Data.SqlClient version: 5.0.0
.NET target: (.NET 6)
SQL Server version: (SQL Server 2005)
Operating system: (Windows 8)

Additional context
System.Data.SqlClient 4.8.3 has the same problem.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions