Sql_server - is this really a bug?

I have just opened up the SQL Server Example - Run it - All good

I have then just changed the Table Name so I can try accessing my own data but am getting a crash
On looking at the message it says
“Error retrieving large column values due to a bug in the SQL Native Client (https://connect.microsoft.com/SQLServer/feedback/details/467300/problem-with-varchar-max-via-sql-native-client).”
Have I done something wrong?
It crashes on the Select * from TableName execution


Sub Action()
If Not IsConnected Then
MessageDialog.Show(“Connect to the database first.”)
End If


Var sql As String = “SELECT * FROM DRS_MASTER;” <<<<<<<<<<<<<<< my change
Var data As RowSet

data = mDB.SelectSQL(sql) <<<<<<<<<<<<<<<<<<<<< crashes here
Catch err as DatabaseException
MessageDialog.Show("DB Error: " + err.Message)
End Try

If data <> Nil Then
For Each row As DatabaseRow In data
DataList.AddRow(row.ColumnAt(0).StringValue, row.ColumnAt(1).StringValue, _
row.ColumnAt(2).StringValue, row.ColumnAt(3).StringValue)


End If

End Sub

There is a bug in SQL Server Native client which is linked in the error message. If you follow the link you’ll see how to mitigate the issue.

This is not a bug in your code but how the Native client processes Varchar(Max) defined columns.

There are two problems when dealing with MS SQL Server Databases that relate to me.

  1. NVARCHAR(MAX) should be defines as NVARCHAR(4000) . If you actually want maximum length storage. Nothing yo stop you defining field as NVARCHAR(2000) for example if you want.

  2. This stores the value as in MS Access called YES/NO. MS SQL Server calls it (BIT null).
    My workaround for this will be to change all NIT definitions to a NVARCHAR(1) Text Field.

I will need to go through my database (all tables) and where I find a MAX or a BIT (The largest Textfield and the smallest data field) I will need to redefine these fields by using the following code:

SQL = " ALTER TABLE table_name ALTER COLUMN column_name datatype ;"

You are saying this problem has been around for a long time and MSoft is responsible for fixing the problem. How is it that I don’t have the problem when accessing the Database using VB6?

1 Like