For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > August 2005 > Using Win32::ODBC to connect with MS Access









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using Win32::ODBC to connect with MS Access
refyl

2005-08-06, 7:26 am

I am a perl beginner,i like to write some small script to finish some simple and iterant works.
I have got a lot of ID and Password of Email of varierist websites.Exactly say,it is nearly 2000.All of this came from a database of a medium forum.I have write a small script to check that whether the passwords are fitted for the User Id.
All the data was deposited in the MS Access.First ,i installed the module Win32::ODBC.i don't want to descript the detail ,if you dont know ,please refer the perl help document about how to install a module.
In the database ,i creat three field mainly ,which were "UserEmail","pwd" and "v_email".v_email was dim as a boolean to decide whether the pwd was valid.
Following was a part of the source code:
code:
use Win32::ODBC; $DSN="MS Access Database"; if(!($db=new Win32::ODBC($DSN))){ print "连接失败"; exit(); } else{ print " 连接成功\n"; } open(EMAIL,">email.txt"); $db->Sql("SELECT * FROM FP_User"); while($db->FetchRow()){ my $pwd=$db->Data('pwd'); my $email=$db->Data('UserEmail'); $v_email=post($email,$pwd); $db->Sql("UPDATE SET 'v_email'='".$v_email."'")||die $db->Error; } close(EMAIL); $db->Close;

Execpt above ,i have define a function POST .If the password was valid ,the the function will return 1,or else ,it will return 0.
Unfortuntly,a error take place once executed.i have do a lot of experiace which proved my fumction POST is excellent,and it could return a expected result.
Base on my attempt ,i think i must have make a mistake when using "$db->Sql".Because everytime i execute the script ,it stops after it loop for once,not fetchrow or movenext ,i.e.s,the sentence "$db->Sql("UPDATE SET 'v_email'='".$v_email."'")||die $db->Error;" had moved the cursor to the end of the recordset.so it skip out quickly,not regard the record behind.
I wish a expert will tell me the right usage of UPDATE.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com