Purba Anggara

Purba Anggara

  • NA
  • 175
  • 5.7k

Database FIrebird Error

May 3 2016 10:28 PM
I want to change the date format in the database storage firebird.
 
code
  1. public int Save(Pegawai PG)  
  2.        {  
  3.            using (FbCommand cmd = conn.CreateCommand())  
  4.            {  
  5.                cmd.CommandText = "Simpanpegawai";  
  6.                cmd.CommandType = System.Data.CommandType.StoredProcedure;  
  7.                cmd.Parameters.AddWithValue("KodePelanggan", FbDbType.VarChar).Value = PG.KodePegawai;  
  8.                cmd.Parameters.AddWithValue("Nama", FbDbType.VarChar).Value = PG.Nama;  
  9.                cmd.Parameters.AddWithValue("TempatLahir", FbDbType.VarChar).Value = PG.TempatLahir;  
  10.                cmd.Parameters.AddWithValue("TanggalLahir", FbDbType.Date).Value = PG.TanggalLahir; //Masukkan Dengan Format Tanggal "dd/mm/yyyy"  
  11.                cmd.Parameters.AddWithValue("JenisKelamin", FbDbType.VarChar).Value = PG.JenisKelamin;  
  12.                cmd.Parameters.AddWithValue("Alamat", FbDbType.VarChar).Value = PG.Alamat;  
  13.                cmd.Parameters.AddWithValue("Telp", FbDbType.Numeric).Value = PG.Telp;  
  14.                cmd.Parameters.AddWithValue("HP", FbDbType.Numeric).Value = PG.HP;  
  15.                cmd.Parameters.AddWithValue("Pendidikan", FbDbType.VarChar).Value = PG.Pendidikan;  
  16.                cmd.Parameters.AddWithValue("IDJabatan", FbDbType.Integer).Value = PG.IDJabatan;  
  17.                cmd.Parameters.AddWithValue("NoRek", FbDbType.Numeric).Value = PG.NoRek;  
  18.                cmd.Parameters.AddWithValue("TanggalMasuk", FbDbType.Date).Value = PG.TanggalMasuk; //Masukkan Dengan Format Tanggal "dd/mm/yyyy"  
  19.                cmd.Parameters.AddWithValue("TanggalKeluar", FbDbType.Date).Value = PG.TanggalKeluar; //Masukkan Dengan Format Tanggal "dd/mm/yyyy"  
  20.                cmd.Parameters.AddWithValue("Foto", FbDbType.VarChar).Value = PG.Foto;  
  21.                cmd.Parameters.AddWithValue("Keterangan", FbDbType.VarChar).Value = PG.Keterangan;  
  22.                return cmd.ExecuteNonQuery();  
  23.            }  
  24.        } 

error:

An unhandled exception of type 'System.FormatException' occurred in FirebirdSql.Data.FirebirdClient.dll  Additional information: String was not recognized as a valid DateTime.
Help Please

Answers (3)