How to serialize and deserialize hashtable dictionary in C # And C # connect to MySQL database

Source: Internet
Author: User

Using system. IO;
Using system. runtime. serialization. formatters. Binary;

Hashtable AA = new hashtable ();

Private void buttonsave_click (Object sender, eventargs E)
{
Filestream FS = new filestream ("E: \ 400tel. dat", filemode. Create );
Binaryformatter BF = new binaryformatter ();
BF. serialize (FS, AA );
FS. Close ();
}

Private void buttonload_click (Object sender, eventargs E)
{
AA. Clear ();
Filestream FS = new filestream ("E: \ 400tel. dat", filemode. openorcreate );
Binaryformatter BF = new binaryformatter ();
AA = (hashtable) BF. deserialize (FS );
FS. Close ();

}

// Dictionary <string, string> DIC = new dictionary <string, string> (13000000 );

C # connect to the MySQL database

String connectionstring = "Server = localhost; user id = xxxx; Password = xxxx; database = XXXX ";
String sqlstring = "... (the SQL statement is omitted here )";
Using (mysqlconnection connection = new mysqlconnection (connectionstring ))
{
Using (mysqlcommand cmd = new mysqlcommand (sqlstring, connection ))
{
Try
{
Connection. open ();
Int rows = cmd. executenonquery (); // execute an SQL statement
Return rows;
}
Catch (MySQL. Data. mysqlclient. mysqlexception E)
{
Connection. Close ();
Throw E;
}
}
}


Download
Mysql-connector-net-6.4.3.rar

Download mysql-connector-net-6.4.3-src.zip

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.