The expression Variant cannot be type-converted to a String value.
The call is ambiguous between the following methods:
'Parameters()'
and
'Parameters()'
SQLConnection := SQLConnection.SqlConnection( 'Provider=SQLOLEDB;Data Source=theServer;' + 'Initial Catalog=theDB;' + 'Integrated Security=SSPI;'); SQLConnection.Open; SQLCommand := SQLConnection.CreateCommand(); SQLCommand.CommandText := 'select count(*)' + ' from [' + COMPANYNAME + '$Sales Line] ss ' + ' where ss.DocType = @DocumentType ' + ' and ss.DocNo = @DocumentNo '; SQLCommand.CommandTimeout := 7200; SQLCommand.CommandType := 1; //SqlParameterCollection := SQLCommand.Parameters; //also doesn't work SqlCommand.Parameters.AddWithValue('@DocumentType', "Document Type"); SqlCommand.Parameters.AddWithValue('@DocumentNo', "No."); SQLReader := SQLCommand.ExecuteReader; IF NOT SQLReader.Read THEN BEGIN LineCount := SQLReader.GetDecimal(0); END; SQLConnection.Close; CLEAR(SQLReader); CLEAR(SQLCommand); CLEAR(SQLConnection);
Name DataType Subtype Length SQLConnection DotNet 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Data.SqlClient.SqlConnection SQLCommand DotNet 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Data.SqlClient.SqlCommand SQLReader DotNet 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Data.SqlClient.SqlDataReader SQLParameter DotNet 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Data.SqlClient.SqlParameter SQLParameterCollection DotNet 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Data.SqlClient.SqlParameterCollection
Answers
Did you find any solution for this error.
i am using dotnet datatype SQLConnection variables.
Any other alternate way to execute store procedure from NAV
kindly help.
Thanks
See http://community.dynamics.com/nav/b/navericwauters/archive/2011/07/19/net-interop-calling-stored-procedures-on-sql-server-example-1.aspx#.UXbjzVfm82x which says:
I need some little help to read data from SqlDataReader using the new DotNet DataType Object. I am trying to assign a decimal value to a C/AL decimal variable using the method GetInt32(Int), but an error occur with the following message: Specified cast is not valid.
Down bellow is my code:
IF rPOSFuncProfile."No Sales Items With No Ivent." = TRUE THEN BEGIN
lSQLConnection := lSQLConnection.SqlConnection(GetConnectionString(rPOSFuncProfile."Sever Name", rPOSFuncProfile.Database,
rPOSFuncProfile.User,rPOSFuncProfile.Password));
lSQLConnection.Open;
lSQLCommand := lSQLConnection.CreateCommand();
SQLStr := 'SELECT SUM([Remaining Quantity]) AS Cantidad ' +
'FROM dbo. ' +
'WHERE [Item No_] = ' + rItem."No." + ' ' +
'AND [Location Code] = ' + SingleQuote + StoreSetup."Location Code" + SingleQuote;
lSQLCommand.CommandText := SQLStr;
lSQLDataReader := lSQLCommand.ExecuteReader();
WHILE lSQLDataReader.Read DO BEGIN
lQueryResult := lSQLDataReader.GetInt32(0);
END;
lSQLConnection.Close;
CLEAR(lSQLConnection);
CLEAR(lSQLCommand);
CLEAR(lSQLDataReader);
IF lQueryResult <= 0 THEN
EXIT(FALSE);
END;
Hopefully you can help me with this. Thanks in advance...