Òò¹¤×÷ÐèÒª£¬Òª½«´æ·ÅÔÚsql serverÊý¾Ý¿âÖеÄÊý¾ÝÈ«²¿µ¼Èëµ½mysqlÊý¾Ý¿âÖУ¬ÔÚÍøÉÏËѼ¯Ïà¹Ø×ÊÁÏ£¬ÕÒµ½Á½ÖÖ·½·¨£¬ÏÖÔÚ·Ö±ð̸̸¶ÔËûÃǵĿ´·¨¡£
µÚÒ»ÖÖÊÇ°²×°mysql ODBC£¬ÀûÓÃsql serverµÄµ¼³ö¹¦ÄÜ£¬Ñ¡ÔñmysqlÊý¾ÝÔ´£¬½øÐÐÊý¾ÝµÄÖ±½Óµ¼³ö£¬ÕâÖÖ·½·¨ºÜ¼ò±ã£¬µ«ÊÇÕë¶Ôʵ¼ÊÓ¦ÓÃÓкܶà±×¶Ë£¬×îÖ÷ÒªÌåÏÖ¾ÍÊÇÊý¾ÝÀàÐÍÎÊÌ⣬Ê×ÏÈ£¬sql serverÊý¾Ý¿âÖÐ
µÄntext,imageµÈÊý¾ÝÀàÐ͵ÄÊý¾ÝÎÞ·¨Ö±½ÓдÈëµ½mysqlÊý¾Ý¿âÖУ¬¾Ý˵ֻҪÉԼӸĶ¯¾Í¿ÉÒÔ£¬¿ÉϧżÕâÖ»²ËÄñ»¹Ã»Ïëµ½ÈçºÎ¸Ä¶¯£¬Æä´Î£¬ÒòΪżÔÚmysqlÖеÄÊý¾Ý¿âÉè¼ÆÖн«Ê±¼ä¶¼Éè³ÉintÐÍ(±£´æµÄÊÇʱ¼ä´Á)£¬ËùÒÔÔÚÊý¾Ýµ¼¹ýÀ´ºó£¬¾Í»á³öÏÖ³åÍ»£¬ÔٴΣ¬ÕâÖÖ·½·¨Éú³ÉµÄmysqlÊý¾Ý±íµÄ×Ö¶ÎÀàÐͶ¼²»ºÜºÏÊÊ£¬ËùÒÔ´ËÖÖ·½·¨ÎÒ¾õµÃ²»ÄÜÌᳫ¡£
µÚ¶þÖÖÊÇÀûÓÃphp»òasp½Å±¾À´ÊµÏÖÊý¾ÝµÄµ¼È빦ÄÜ£¬ÕâÖÖ·½·¨ÐèÒª±àд³ÌÐò£¬µ«Áé»îÐԴ󣬲Ù×÷Ò²²»ÊÇÄÇôÀ§ÄÑ£¬Ò»Çж¼¾¡ÔÚÄãµÄÕÆÎÕÖ®ÖУ¬ÏÖ¼òµ¥½éÉÜһϸ÷½·¨
Ç°ÌáÌõ¼þÊÇÄãµÄmysql»·¾³ÒѾ´î½¨ºÃÁË£¬ÏȽ¨ºÃÄ¿±êÊý¾Ý¿â£¬ÔÙ½«ËùÓеıí½á¹¹ÓÃsqlÓï¾äÉú³É£¬ÏÖÔÚÍòʾ߱¸£¬Ö»È±Êý¾ÝÁË¡£
¿ÉÒÔͨ¹ýÏÂÃæµÄphp½Å±¾À´ÊµÏÖsql serverÖÐmydbÊý¾Ý¿âµÄuser±íÖÐÊý¾ÝÏòmysqlÖÐmydbÊý¾Ý¿âµ¼Èë
$cnx = odbc_connect('web', 'admin', '123456');//'web'ÊÇsqlserverÖÐmydbµÄÊý¾ÝÔ´Ãû£¬'admin'ÊÇ·ÃÎÊmydbµÄÓû§Ãû£¬'123456'ÊÇ·ÃÎÊmydbµÄÃÜÂë
$cur= odbc_exec( $cnx, 'select * from user' );//´ò¿ªsql serverÖÐmydbÊý¾Ý¿âµÄuser±í
$num_row=0;
$conn=mysql_pconnect("localhost","root","123456");// Á¬½Ómysql
@mysql_select_db('mydb',$conn) or
die("ÎÞ·¨Á¬½Óµ½Êý¾Ý¿â£¬ÇëÓë¹ÜÀíÔ±ÁªÏµ£¡");//´ò¿ªmysqlµÄmydbÊý¾Ý¿â
while( odbc_fetch_row( $cur )) //´Ósql serverµÄmydb¿âÖеÄuser±íÖðÌõÈ¡³öÊý¾Ý£¬Èç¹û¶ÔÊý¾Ý½øÐÐÑ¡Ôñ£¬¿ÉÔÚÇ°ÃæµÄselectÓï¾äÖмÓÉÏÌõ¼þÅжÏ
{
$num_row++;
$field1 = odbc_result( $cur, 1 ); // ÕâÀïµÄ²ÎÊýi(1,2,3..)Ö¸µÄÊǼǼ¼¯ÖеĵÚi¸öÓò£¬Äã¿ÉÒÔÓÐËùÑ¡ÔñµØ½øÐÐÑ¡È¡£¬fieldiµÃµ½¶ÔÓ¦ÓòµÄÖµ£¬È»ºóÄã¿ÉÒÔ¶Ôfieldi½øÐвÙ×÷
$field2 = odbc_result( $cur, 2 );
$field3 = odbc_result( $cur, 3 );
$field4 = odbc_result( $cur, 4 );
$field5 = odbc_result( $cur, 5 );
$field6 = odbc_result( $cur, 6 );
$field5 = timetoint($field5); //ÕâÀïÊǶÔsql serverÖеÄdatetimeÀàÐ͵Ä×ֶνøÐÐÏàӦת»»´¦Àí£¬×ª»»³ÉÎÒËùÐèÒªµÄintÐÍ
$querystring = "insert into user
(id,name,username,password,recdate)
values('$field1','$field2','$field3','$field4','$field5')" ;
mysql_query($querystring,$conn);
}
function timetoint($str){
$arr1=split(" ",$str);
$datestr=$arr1[0];
$timestr=$arr1[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;
}
?>
½«¸Ã¶Î½Å±¾´æ³Ésql.php£¬ÔÚ·þÎñÆ÷ÉÏÖ´ÐУ¬¾Í¿ÉÒÔ½«·þÎñÆ÷ÉÏsql serverÖÐmydbÊý¾Ý¿âµÄuser±íÖеÄÊý¾Ýµ¼Èëµ½mysqlÖÐmydbÊý¾Ý¿âµÄuser±íÖÐÈ¥¡£ÆäËû±íµÄ²Ù×÷Óë´ËÀ×ͬ£¬¾Í²»×¸ÊöÁË¡£
ÏÂÃæÔÙ½éÉÜÒ»ÏÂasp½Å±¾ÊµÏÖsql serverÖÐmydbÊý¾Ý¿âµÄÊý¾ÝÏòmysqlÖÐmydbÊý¾Ý¿âµ¼Èë
<%
set conn=server.createobject("adodb.connection")
conn.open 'web', 'admin', '123456' // 'web'ÊÇsqlserverÖÐmydbµÄÊý¾ÝÔ´Ãû£¬'admin'ÊÇ·ÃÎÊmydbµÄÓû§Ãû£¬'123456'ÊÇ·ÃÎÊmydbµÄÃÜÂë
set rs=server.createobject("adodb.recordset")
sql="select ID,name,username,password,datediff(s,'1970-01-01 00:00:00',recdate)-8*3600,reid,filename,fileContentType,filevalue from senddate" //ÕâÌõsqlÓï¾äʵÏÖÁ˽«datetimeÀàÐ͵Ärecdate×Ö¶Îת»¯³Éunixʱ¼ä´ÁµÄintÐÍ
rs.open sql,conn,1,3
set conn1=server.createobject("adodb.connection")
conn1.open "myoa","root","q1-d6=7?"
i=1
do while not rs.eof
field1 = rs(0)
field2 = rs(1)
field3 = rs(2)
field4 = rs(3)
field5 = rs(4)
sql1 = "insert into user(ID,name,username,password,recdate)
values("&field1&",'"&field2&"','"&field3&"','"&field4&"',"&field5&")"
conn1.execute sql1
rs.movenext
i=i+1
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
conn1.close
set conn1=nothing
%>
ÒÔÉÏÁ½¸öÊÇ·Ö±ð²ÉÓÃphp½Å±¾ºÍasp½Å±¾¶Ôuser±íµÄÊý¾Ý½øÐÐÓÉsql serverµ½mysqlµÄµ¼ÈëÆä¼äÎÒ²ÉÓÃ2Öֻرܵķ½·¨À´±ÜÃântext,imageÀàÐÍÊý¾ÝµÄ´«µÝ£¬Ò»ÖÖÊǽ«ntext×ֶθÄΪnvarchar(4000)£¬ÒòΪʵ¼ÊÇé¿ö£¬ÔʼÊý¾ÝÖиÃ×ֶεÄÊý¾Ý³¤¶È¶¼Î´³¬¹ý4000¸ö×Ö£¬ËùÒÔ²¢Ã»ÓгöÏÖÊý¾Ý½Ø¶Ï£¬ÁíÒ»¸öÊÖ¶ÎÊǽ«imageÀàÐÍÊý¾ÝÈ¡³öÀ´Ð´µ½ÎļþÖУ¬ÒÔÎļþÐÎʽ±£´æ£¬½«Îļþ·¾¶´æµ½Êý¾Ý¿âÖУ¬·½·¨¼ûÏ£º
function makeattach(fileContentType,filevalue,i)
select case fileContentType
case "application/msword"
ext="doc"
case "application/vnd.ms-excel"
ext="exl"
case "application/vnd.ms-powerpoint"
ext="pps"
case "application/x-rar-compressed"
ext="rar"
case "application/x-zip-compressed"
ext="zip"
case "image/gif"
ext="gif"
case "image/pjpeg"
ext="jpg"
case "text/plain"
ext="txt"
case else
ext="x"
end select
if ext<>"x" then
set fso=server.createobject("FileSystemObject")
fName="attech"&i&"."&ext
Dir="d:attach"
If fso.FileExists(Dir & fName) Then fso.deletefile Dir & fName
If fName<>"" AND NOT fso.FileExists(Dir & fName) Then
Set strm1=Server.CreateObject("ADODB.Stream")
strm1.Open
strm1.Type=1 'Binary
strm1.Write filevalue
strm1.SaveToFile Dir & fName,2
Set strm1=Nothing
end if
makeattach=fName
end if
end function
Õâ¸öº¯ÊýÓÐ3¸öÊäÈë²ÎÊý£¬µÚÒ»¸öÊÇÎļþµÄcontentType£¬µÚ¶þ¸öÊÇÎļþµÄ¶þ½øÖÆÊýÖµ£¬µÚÈý¸öÊǸö¿ÉÒÔÇø±ðÎļþÃûµÄ±äÁ¿£¬Ïȸù¾ÝcontentTypeÈ·¶¨Ëù´æÎļþµÄºó׺Ãû£¬È»ºó¾ÍÊǽ«¶þ½øÖÆÊýÖµ±£´æ³ÉÖ¸¶¨ÎļþÃûµÄÎļþ£¬²¢½«ÎļþÃû×÷ΪÊä³ö²ÎÊý·µ»Ø£¬½«·µ»ØµÄ²ÎÊý×÷ΪÊý¾Ýдµ½mysqlµÄÊý¾Ý¿âÖб£´æ¡£
ʱ¼ä´Ò棬ÏÈ×ܽᵽÕâÀϣÍûÕâЩÎÄ×ÖÄܶÔÓÐÐèÒªµÄÈËÓÐЩ°ïÖú£¬ÉÙ×ßЩÍä·£¬¸ÐлÄúµÄÔĶÁ¡££º£©