Provincial Office newspaper 7.0 read MDB generate XML file

Source: Internet
Author: User

Using System;
Using System.Collections.Generic;
Using System.Data;
Using System.Data.OleDb;
Using System.IO;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;

Namespace ConsoleApplication1
{
Class Program
{
static void Main (string[] args)
{

Try
{
var address = @ "C:\Users\Administrator\Downloads\JSYD". mdb ";
String str = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + address + "'";
var con = new OleDbConnection (str);
Con. Open ();
OleDbCommand cmd = con. CreateCommand ();

Get the data

OleDbDataAdapter dagroup = new OleDbDataAdapter ("SELECT * from T_zd_type", con);
DataSet Dsgroup = new DataSet ();
Dagroup. Fill (Dsgroup, "Ddgroup");
var dt = Dsgroup. Tables[0];
var str1 = "";
for (int i = 0; i < dt. Rows.Count; i++)
{
var type = dt. rows[i]["TYPE"];
var mc = dt. rows[i]["MC"];
var dm = dt. rows[i]["DM"];
var typebz = dt. rows[i]["Typebz"];
STR1 + = string. Format ("<dict name = ' key = ' {0} ' value = ' {1} ' type = ' {2} ' desc = ' {3} '/>\r\n", DM, MC, type, TYPEBZ);
}
Writelogfile (STR1);
Con. Close ();
Con. Dispose ();

}

catch (Exception ex)
{
Con. Close ();
Con. Dispose ();
Throw ex;
}

}

/**/
<summary>
Write log file
</summary>
<param name= "Input" ></param>
public static void Writelogfile (String input)
{
/**/
Specify the directory for the log file
String fname = Directory.GetCurrentDirectory () + "\\LogFile.txt";
/**/
Defining File Information objects

FileInfo finfo = new FileInfo (fname);

if (!finfo. Exists)
{
FileStream FS;
FS = File.create (fname);
Fs. Close ();
Finfo = new FileInfo (fname);
}

/**/
Determine if the file exists and is greater than 2K
if (finfo. Length > 1024 * 1024 * 10)
{
/**/
File is renamed over 10MB
File.move (Directory.GetCurrentDirectory () + "\\LogFile.txt", directory.getcurrentdirectory () + DateTime.Now.TimeOfDay + "\\LogFile.txt");
/**/
Delete the file
Finfo. Delete ();
}
Finfo. AppendText ();
/**/
Create a write-only file stream

using (FileStream fs = Finfo. OpenWrite ())
{
/**/
Create a write stream based on the file stream created above
StreamWriter w = new StreamWriter (FS);

/**/
Sets the starting position of the write stream to the end of the file stream
W.basestream.seek (0, Seekorigin.end);

/**/
Write "Log Entry:"
W.write ("\n\rlog Entry:");

/**/
Write the current system time and wrap
W.write ("{0} {1} \n\r", DateTime.Now.ToLongTimeString (),
DateTime.Now.ToLongDateString ());

/**/
Write the log contents and break the line
W.write (input + "\n\r");

/**/
Write------------------------------------"and wrap
W.write ("------------------------------------\n\r");

/**/
Empties the buffer contents and writes the buffer contents to the underlying stream
W.flush ();

/**/
Turn off write Data flow
W.close ();
}

}
}
}

Provincial Office newspaper 7.0 read MDB generate XML file

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.