String is converted into invalid UTF-8 characters when passed into model from controller

Huzaifa Sajid 0 Reputation points
2024-11-21T07:57:29.0866667+00:00

Controller:

DataTable dtt = new CommonModel().ManualQuerySelect("select isnull(ReportTitle,'Journal Voucher') from gen_VoucherTypes where VoucherType = 6 and LogSourceID = 0", clsCommon.AccountsnewConnectionString).Tables[0];

Model:

public DataSet ManualQuerySelect(string Query, string NewConnection, int CommandTimeout=0)

    {

        if(NewConnection != "")

        {

            SqlDatabase db = new SqlDatabase(NewConnection);

            DbCommand SPCommand = db.GetSqlStringCommand(Query);

            SPCommand.CommandTimeout = CommandTimeout;

            return db.ExecuteDataSet(SPCommand);

        }

        else

        {

            DataSet ds = new DataSet();

            return ds;

        }

    }

Issue is that i get 漀甀挀栀攀爀䤀䐀 㴀 笀 紀Ⰰ 䴀愀渀愀最攀 㴀 笀㄀紀Ⰰ 倀愀爀琀礀吀椀琀氀攀 㴀  in Model string Query parameter

Untitled

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,536 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.