FEBY JOSEPH

FEBY JOSEPH

  • NA
  • 4
  • 35.8k

[ODBC Microsoft Access Driver]Invalid precision value

Jan 19 2011 2:26 AM
ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value

Hello All,
Please help me to resolve this error( Invalid precision value ) which I am getting from C # application  when i am trying to insert IMAGES( BINARY  FORMAT ) to the database(  DB = MS Access ).
here is my code:
  1. private void btnSaveToDB_Click(object sender, EventArgs e)  
  2. {  
  3.     OdbcConnection odbcConnection = null;  
  4.     OdbcCommand odbcCommand = null;  
  5.     try  
  6.     {  
  7.         odbcConnection = new OdbcConnection(@"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\TestFP.mdb;Uid=;Pwd=;");  
  8.         odbcConnection.Open();  
  9.         odbcCommand = odbcConnection.CreateCommand();  
  10.         odbcCommand.CommandText = "INSERT INTO Employee ( Name ,FingerImage_1 ) VALUES (?,?)";  
  11.         System.Data.Odbc.OdbcParameter nameFiled = new System.Data.Odbc.OdbcParameter();  
  12.         nameFiled.OdbcType = System.Data.Odbc.OdbcType.Text;  
  13.         nameFiled.ParameterName = @"Name";  
  14.         nameFiled.Value = @"My Name";  
  15.         odbcCommand.Parameters.Add(nameFiled);  
  16.         System.Data.Odbc.OdbcParameter imageField_1 = new System.Data.Odbc.OdbcParameter();  
  17.         imageField_1.OdbcType = System.Data.Odbc.OdbcType.Binary;  
  18.         imageField_1.ParameterName = @"FingerImage_1";  
  19.         imageField_1.Value = _mainDialog._imageStream_1.ToArray();                                                  
  20.         odbcCommand.Parameters.Add(imageField_1);                                  
  21.         int rows_affected = odbcCommand.ExecuteNonQuery(); //RUN TIME ERROR  = System.Data.Odbc.OdbcException: ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value  
  22.     }  
  23.     catch (Exception ex)  
  24.     {  
  25.         MessageBox.Show(ex.Message);  
  26.     }  
  27.     finally  
  28.     {  
  29.          odbcConnection.Close();  
  30.     }  
  31. }  
HERE is the Run Time Error  
 
System.Data.Odbc.OdbcException: ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]Invalid precision value 
I know that  there is a property  as follows 
  1. OdbcParameter.Precision   
but how do i set "OdbcParameter.Precision"  if my data (  which is inserted to database ) in binary format.....?
Please help me
Thanks in advance