Save Captured Signature Image to Database

It is very easy to complete this job as the server control provide you two properties: imageMemoryStream and imageBytes. Using imageBytes will be more easily to save image to database such as SqlServer.

Sample Code for saving signature to Database

Full source code is provided in the download file.

            if (!WebSignature1.ExportToStreamOnly()) return;
            if (WebSignature1.imageBytes.length < 100) return;
            SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["WebSignatureConnectionString"].ToString());
            SqlCommand myCommand = new SqlCommand("insert into WebSignature (signatureImage,ip) values(@signatureImage,@ip)", myConnection);
            myCommand.Parameters.Add("@signatureImage", SqlDbType.Image).Value = WebSignature1.imageBytes;
            myCommand.Parameters.Add("@ip", SqlDbType.VarChar).Value = Page.Request.UserHostAddress.ToString();
            try
            {
                myConnection.Open();
                myCommand.ExecuteScalar();
            }
            catch (Exception e) {}
            myCommand.Dispose();
            myConnection.Close();