3
I am trying to solve a patch error of converting a variable created by me to store data that is in an Excel sheet.
The error happens when I try to insert the data that is in this variable in SQL Server
, ie in (query).
code:
variable declaration:
string valmoradafiscaligualmoradalocal = "";
information search code:
case 47://coluna 21
if (((WS.Cells[linha, Contcoluna] as Excel.Range).Value) != null)
{
valmoradafiscaligualmoradalocal = Convert.ToString((WS.Cells[linha, Contcoluna] as Excel.Range).Value);
}
continue;
insert code in sql server:
cmd.CommandText = "INSERT tabela_sacc (Morada_Fiscal_Igual_a_Morada_Local) VALUES ('" + valmoradafiscaligualmoradalocal.ToString() + "')";
connection.Open();
cmd.Connection = connection;
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
connection.Close();
valgrupo = null;
It’s really not possible to convert a nay or a yes for a tinyint, there is no function for this, what can be done is a case or a function that does this. in any case your question is not clear enough to make a good answer.
– Marco Souza