byte array stored in MySQL

Source: Internet
Author: User
Tags mysql query

  Public intAddveinmessage (byte[] data)//Insert Database {using(Bcssqlconnection =Newmysqlconnection (strconn)) {                Try{dbhelper=NewDBHelper (bcssqlconnection); StringBuilder Sbsql=NewStringBuilder (); Sbsql.append ("INSERT INTO table1 ("); Sbsql.append ("data)"); Sbsql.append ("VALUES ("); Sbsql.append ("? data)"); stringStrinsertsql =sbsql.tostring (); Mysqlcommand cmd=Dbhelper.getsqlstringcommond (Strinsertsql); Dbhelper.addinparameter (cmd,"? data", Mysqldbtype.varbinary, Fingerdata); returndbhelper.executenonquery (CMD); }                Catch(Exception ex) {System.Windows.Forms.MessageBox.Show ("Add has failed"+Ex.                    Message); return 0;//represents a database exception                }                finally{dbhelper.closesqlconnection (); //Close the database                }            }        }

Remove from Database

 PublicDataTable selectveinmessage () {using(Bcssqlconnection =Newmysqlconnection (strconn)) {                Try{StringBuilder Sbsql=NewStringBuilder (); Sbsql.append ("Select data from table"); //set up a MySQL query statement to query for records that match the query criteria                    stringstrSQL =sbsql.tostring (); DBHelper=NewDBHelper (bcssqlconnection); //Call the Getsqlstringcommond () method in the DBHelper class to assign the returned Mysqlcommand object to cmdMysqlcommand cmd =Dbhelper.getsqlstringcommond (strSQL); //dbhelper.addinparameter (cmd, "?)                    Fingerdata ", Mysqldbtype.varchar, Fingerdata); //Call the ExecuteDataset () method of the DBHelper classDataTable dt =dbhelper.executedatatable (CMD); //return DataTable Object DT                    returnDT; }                Catch(Exception e) {Throw NewException (e.message); }                finally{dbhelper.closesqlconnection (); }            }        }
DataTable dt = mm. SelectVeinMessage1 ();             byte New byte [+];              for (int0; i < dt.) Rows.Count; i++)            {                = (byte[]) dt. rows[i]["data"];                       

byte array stored in MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.