onaopepo 0 Newbie Poster

Hi,i m presently working on a project in which i am to store a fingerprint image gotten from a fingerprint reader into a database.I am using the web service too and i have been at this for a pretty long while.i ll be very grateful if theres anyone out there to help.the codes i wrote are written below and i ll also appreciate it if the solution is kept simple and explanations proffered because i m new to c#.thanks.

  [WebMethod]
        public bool AddTemplate(byte[] template)

        {
            MySqlConnection conn = new MySqlConnection(query);
            MySqlCommand cmdInsert = null;
            MySqlParameter dbParamInsert = null;
            MySqlCommand cmdSelect = null;
            GrFingerXCtrlClass gr = new GrFingerXCtrlClass();
            InitializeGrFinger(gr);
            TTemplate tpt = new TTemplate();
            //tpt._size = size;

            int id;

            try
            {

                cmdInsert = new MySqlCommand("INSERT INTO medical_records(fingerprint) values(?) ", conn);
                 //Create parameter for ? contained in the SQL statement.

                //System.Byte[] temp = new System.Byte[tpt._size + 1];
                //System.Array.Copy(tpt._tpt,0,template,0,tpt._size);
                /*dbParamInsert = new MySqlParameter("?fingerprint", MySqlDbType.VarBinary, template.Count(),
                               ParameterDirection.Input, false, 0, 0, "ID",
                               DataRowVersion.Current, temp);*/
               dbParamInsert = new MySqlParameter("@fingerprint", MySqlDbType.VarBinary, template.Count(),
                               ParameterDirection.Input, false, 0, 0, "id_no",
                               DataRowVersion.Current, template);

                cmdInsert.Parameters.Add(dbParamInsert);

                //execute query
                if (conn.State == ConnectionState.Open)
                cmdInsert.ExecuteNonQuery();
            }
            catch
            {
                return false;
            }
return true;
}

on the client-side,i have

public int Enroll() 
    {
        int id = 0;
        // Checks if template is valid.
        if (TemplateIsValid())
        {
            // Adds template to database and returns template ID.
            Service1SoapClient client = new Service1SoapClient();
            System.Byte[] template = new System.Byte[_tpt._size + 1];
            System.Array.Copy(_tpt._tpt , 0,template,0,_tpt._size);
            //client.AddTemplate(template,ref id);
            client.AddTemplate(template);

            return id;

        } 
        else 
        {
            return -1;
        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.