I trying to make a backend method call work which connects to database and executes the record in a table. The method call works perfectly and it is not throwing any error but at the same time it does not update any record in the table.
Note:
- SELECT query returns the data as expected.
- It is insert and update that does not work as expected.
Here is my method snippet which connects the database and tries to execute update query with ExecuteNonQuery()
method.
public void Update(Insights ins)
{
string DbConnection = ConnectionSetting.ConnectDatabricks();
string query = @"UPDATE Archery SET Insight = '?', Title = '?' WHERE Sub_Topic = '?'";
try
{
using (OdbcConnection connection = new OdbcConnection(DbConnection))
{
connection.Open();
OdbcCommand command = new OdbcCommand(query, connection);
command.CommandText = query;
command.Parameters.Add("@insight", OdbcType.NVarChar).Value = ins.Insight;
command.Parameters.Add("@title", OdbcType.NVarChar).Value = ins.Title;
command.Parameters.Add("@subject", OdbcType.NVarChar).Value = ins.Subject;
command.ExecuteNonQuery();
}
}
catch (Exception)
{
throw;
}
}
The table schema is as below:
Column Name Type
InsightId BigInt (primary key)
Insight String
Title String
Subject String