alti balla

alti balla

  • NA
  • 14
  • 1.2k

Conversions from c# to odbc sql server

Jun 8 2020 8:21 AM
 hello ,
 
im having a problem converting from datetime c# to datetime sql server using odbc and time c# to time(7) sql server this is my code: 
 
command.CommandText = "INSERT INTO pointer (Nom_employe, Date_Heure , Matin, Midi, apresmidi, Soir) VALUES ( ? ,? , ? , ?, ?, ?);";
// command.Parameters.AddWithValue("datetime", date_heure);
// command.Parameters.AddWithValue("nom", nom_employe);
command.Parameters.Add("@Nom", OdbcType.VarChar).Value = nom_employe;
command.Parameters.Add("@Date", OdbcType.Date).Value = Convert.ToDateTime( date_heure);
if (matin == null)
{
command.Parameters.Add("@Matin", OdbcType.Time).Value = null;
}
else
{
command.Parameters.Add("@Matin", OdbcType.Time).Value = TimeSpan.Parse(matin);
}
if (midi == null)
{
command.Parameters.Add("@Midi", OdbcType.Time).Value = null;
}
else
{
command.Parameters.Add("@Midi", OdbcType.Time).Value = TimeSpan.Parse(midi);
}
if (Apresmidi == null)
{
command.Parameters.Add("@Apresmidi", OdbcType.Time).Value = null;
}
else
{
command.Parameters.Add("@Apresmidi", OdbcType.Time).Value = TimeSpan.Parse( Apresmidi);
}
if (Soir == null)
{
command.Parameters.Add("@Soir", OdbcType.Time).Value = null;
}
else
{
command.Parameters.Add("@Soir", OdbcType.Time).Value = TimeSpan.Parse(Soir);
}
 
 
 
this is the error i am getting now : 'ERROR [HYC00] [Microsoft][ODBC SQL Server Driver]Fonctionnalité optionnelle non implémentée'
 
but befor this i had other errors about conversions and i dedn't manage to fix so i think the problem is still here ?
 
can i have some help please i have to deliver soon? 
 

Answers (2)