Well, I have been supported by all of you have now succeeded in switching access data to MySQL form, I will dedicate to those who need friends!

Source: Internet
Author: User
Tags dsn connect odbc mysql split access database
access|mysql| data The first step, do a good job of database preparation. Install data source (this will cost me several days), first click on the Control Panel
ODBC data Source (32-bit)
, click to enter after the selection
User DSN (in fact, default)
, in which you select
For MS ACCESS, click the Configure button to the right of this option.
Will come out a window name is: [Odbc Microsoft Installation].
Select the database you want to call in the section. (Select the selection button)
Then click on the Advanced option on its right, which will pop up an [advanced settings option] To set the user's password and username (each name is well written) and click on the option type below the column
DefaultDir, enter your database (ie, Access database) at the bottom of the number. Then decide to return to the original location (user DSN), then start [Add] The data source you just added, select *.mdb (Access), click Finish. Go to another page, in the beginning of the data source: Data your database Source name: (for example, I used to be taici.mdb, then now enter the Taici in it). Then be sure to select the database you are looking for. Okay, now the database is ready to go.

The second step, that is the problem of program switching.
?
$CNX = Odbc_connect (' Taici ', ' Admin ', ' WSD ');
Do you remember? Teach you to enter user and password time call you remember good, is admin and WSD, know how to do?!
$cur = odbc_exec ($CNX, ' select * from word ');
Word is one of the tables Taici
$num _row=0;
$conn =mysql_pconnect ("localhost", "WSD", "WSD");//Connect MySQL
@mysql_select_db (' SMS ', $conn) or

Die ("Unable to connect to the database, please contact the Administrator!") ")//Open MySQL's mydb database
while ($cur)//Odbc_fetch_row from the user table in the SQL Server's MyDB library, if you select the data, you can add conditional judgments to the previous SELECT statement
{
$num _row++;
$field 1 = Odbc_result ($cur, 1); Here's the parameter I (1,2,3 ...) Refers to the first domain in the recordset, where you can selectively select, Fieldi get the value of the corresponding field, and then you can manipulate the Fieldi
$field 2 = Odbc_result ($cur, 2);
$field 3 = Odbc_result ($cur, 3);
$field 4 = Odbc_result ($cur, 4);
$field 5 = Odbc_result ($cur, 5);
$field 6 = Odbc_result ($cur, 6);
$field 7 = Odbc_result ($cur, 7);
$field 3 = Timetoint ($field 3); Here is the corresponding conversion of the DateTime type fields in SQL Server to the type I need int
$querystring = "INSERT INTO Tab_phrase
(Phrase_content,phrase_number,phrase_inputtime,phrase_author,phrase_classid,phrase_flag,phrase_fee)
VALUES (' $field 1 ', ' $field 2 ', ' $field 3 ', ' $field 4 ', ' $field 5 ', ' $field 6 ', ' $field 7 ') ";

mysql_query ($querystring, $conn);
}

function Timetoint ($STR) {
$arr 1=split ("", $str);
$DATESTR = $arr 1[0];
$TIMESTR = $arr 1[1];
$arr _date=split ("-", $datestr);
$arr _time=split (":", $TIMESTR);
$year = $arr _date[0];
$month = $arr _date[1];
$day = $arr _date[2];
$hour = $arr _time[0];
$minute = $arr _time[1];
$second = $arr _time[2];
$time _int=mktime ($hour, $minute, $second, $month, $day, $year);
return $time _int;
}
?>

Well, after writing for so long, have a question to say hello again.


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.