Marius0188
asked on
Delphi 7 :: ADOQuery :: MS SQL 2005 Express Help
Dear Experts,
I have a SQL 2005 database with a table.
A field in the table is of type: nvarchar(max).
When comparing values ina SELECT statement II get an error like this:
"The data types nvarchar(max) and ntext are incompatible in the equal to operator"
This is my query:
function TfrmMain.CheckIfPrejigExis ts(const AFileName: WideString): Boolean;
begin
qView.SQL.Text := 'SELECT ID from tblPrejig WHERE PrejigFileName = :PrejigFileName';
qView.Parameters.ParamByNa me('Prejig FileName') .Value := AFileName;
qView.Open;
qView.Last; qView.First;
Result := qView.RecordCount > 0;
end;
The parameter AFilename is a WideString and it is not compatible with my field type nvarchar(max).
What types should I use in my table for strings and still be ok with WideString / String etc in Delphi?
Thanks in advance
I have a SQL 2005 database with a table.
A field in the table is of type: nvarchar(max).
When comparing values ina SELECT statement II get an error like this:
"The data types nvarchar(max) and ntext are incompatible in the equal to operator"
This is my query:
function TfrmMain.CheckIfPrejigExis
begin
qView.SQL.Text := 'SELECT ID from tblPrejig WHERE PrejigFileName = :PrejigFileName';
qView.Parameters.ParamByNa
qView.Open;
qView.Last; qView.First;
Result := qView.RecordCount > 0;
end;
The parameter AFilename is a WideString and it is not compatible with my field type nvarchar(max).
What types should I use in my table for strings and still be ok with WideString / String etc in Delphi?
Thanks in advance
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this solution:
qView.SQL.Text := 'SELECT ID from tblPrejig WHERE rtrim(convert(char(200), PrejigFileName)) = :PrejigFileName';
qView.SQL.Text := 'SELECT ID from tblPrejig WHERE rtrim(convert(char(200), PrejigFileName)) = :PrejigFileName';
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oops, I forget plus sign : AFileName + '%';
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, I have actually see where I went wrong.
My field type should be varchar() and not nvarchar().
Let's split the points....
My field type should be varchar() and not nvarchar().
Let's split the points....
ASKER
nvarchar(50) it is working.
But 50 my be too short for my field length.
Any suggestions.
Thanks!