Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Win32::ODBC Error 1

Status
Not open for further replies.

WoodyRoundUp

Programmer
Feb 28, 2001
187
AU
hi guys. i am facing a big trouble here. my cgi script can't run, just because of the dsn failure. it can't connect to the access db, although i set the system dsn already.

the error msg is like this:
Error connecting to DSN=myDatabase.
Error: [-1023] [] "[Microsoft][ODBC Microsoft Access 97 Driver] '(unknown)' isn't a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides."

can anybody tell me how i deal with it? thanks
 
Is your ODBC Data Source defined on your local box?

If not, you need to do that first.
START->Control Panel->Data Sources(ODBC)->Typical Windows Wizard

If so, check it's properties, especially it's name. You might use some another application (EXCEL, maybe) to connect and prove that your ODBC data source setup is valid and working. Once your sure that your local box sees your Access DB as a valid data source, then make sure that you are calling it correctly from Perl...... should look something like.....

#!perl
use Win32::ODBC;

#Connect
$db = new Win32::ODBC("DSN=MyDatabase;UID=who_ever;PWD=what_ever")
or die "Failed to connect, Win32::ODBC::Error()";

If this does not help you sniff out the problem, post your connect syntax so we can take a look.

HTH



keep the rudder amid ship and beware the odd typo
 
My Connect String is:

$DSN="DSN=myDatabase";

if (!($database2 = new Win32::ODBC($DSN))){
print Win32::ODBC::Error();
exit;
}

thanks.
 
or should i install microsoft access in my web server? thanks again.
 
Sorry, .... don't know. I use DBD::ODBC to connect with an SQL Server on a second machine. On my local machine, I set it up as an ODBC data source and then used the approach described above. I would hope that if you have the Access file setup as an ODBC data source on your web server machine, that the DBD::ODBC stuff would work. I don't have time to go digging just now. Sorry to leave you hanging.




keep the rudder amid ship and beware the odd typo
 
thanks for your reply. it's alrite. i'll try my own, maybe i will install access in my web server first.
thanks.
 
hi goBoating.
i change my mind. i am now using dbi. but, it still shows the same error message.
i installed the dbi and dbd::eek:dbc already. and i set my sytem dsn already.
i connect to two database at one time.
but, still the same error message as previous, but this is a longer one. let me copy it.

DBI->connect(ForumDB) failed: [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. (SQL-S1009)(DBD: db_login/SQLConnect err=-1) at D:\InetPub\ line 71

DBI->connect(myDatabase) failed: [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'DriverId'. (SQL-S1000)(DBD: db_login/SQLConnect err=-1) at D:\InetPub\ line 72

do u have any clue how this happened? i got really fade up with it already. the cgi script can run if we do not connect to the database.

the connect string is like this:

use DBI;
use DBD::ODBC;

$database1 = DBI->connect("DBI:ODBC:ForumDB", "", "");
$database2 = DBI->connect("DBI:ODBC:myDatabase", "", "");

so? i am waiting for your answer. thanks in advance. :)
 
or is that because i set the IIS wrongly?
because for the moment i can still see the local path on the net. if so, pls tell me how should i set the IIS...i am quite new to the perl database..and also to the iis..just started learning last week...
really depend on u guys...
bye......c u
 
I wish I could be more help. I do very little in Win OSs, recently. I live in the UNIX/Apache world for the most part, now.

My best, but limited, advice would be to break the situation down into basic chunks of functionality and make each one work. I don't know anymore detail and don't have Access to play with to figure it out.

First, setup your ODBC data source on the machine (web server box) that is trying to run the code and make the ODBC connection. The Win OS should tell you if it can not attach the data source name to the Access file.

Second, use EXCEL or ACCESS or similar to fire a query at that ODBC data source. Make this work. There is no reason to do anything else until you have the much working on the web server box.

Third, write a very short piece of Perl to make a connection. Something like.....
Code:
    #!perl
    # trying to connect to stagesrv with PERL DBD::ODBC
    use Win32::ODBC;
    print "Trying to connect\n"; 
    $db = new Win32::ODBC("
[red]DSN=sqlServer;UID=someone;PWD=test[/red]
Code:
") 
	or die Win32::ODBC::Error();
    if ($db) { $db->Close(); }
    print "Closed db handle\n";

Fourth, get a simple cgi app to connect with something like....
Code:
    #!perl 
    use CGI;
    use Win32::ODBC;
    $cgi = new CGI;
    print $cgi->header,$cgi->start_html;
    print &quot;<P>Trying to connect<BR>\n&quot;;

    $db = new Win32::ODBC(&quot;
[red]DSN=sqlServer;UID=someone;PWD=test[/red]
Code:
&quot;) ;
    if ($error =  Win32::ODBC::Error())
        {
        print &quot;ERROR - $error<BR>\n&quot;;
        print $cgi->end_html;
        die;
        }
    else 
        {
        print &quot;Yea! It worked.  Connection Successful<BR>\n&quot;;
        if ($db) { $db->Close(); }
        print &quot;Closed db handle<BR></P>\n&quot;;
        print $cgi->end_html;
        }

Fifth, install the working logic into the piece of code you are working on.

I have not run the above code. They should be pretty close. Obviously, change you connect parameters to match you datasource.

HTH
Good Luck.


keep the rudder amid ship and beware the odd typo
 
thanks before.
is there any effect if i use access 2000 as my db while the odbc one is access 97?
 
I would expect it to be entirely possible that different versions of Access would require different ODBC setups. That is how M$ does bussiness, isn't it....... keep things moving so you have to keep getting/buying the next best iteration. Best I can suggest is that you work the first and second steps listed above until you get a connection.

HTH


keep the rudder amid ship and beware the odd typo
 
i have solved the problem. :)
u know what? just because of Access 2000 problem. really a stupid error. :)
feeling relief now.
and another problem now.
why my &quot;usr/lib/sendmail&quot; can't send any email?
what's the problem?
and then, how do i set the my IIS path?
i wanted to upload something inside my server also.
but, can't find the path. how then?
really great solution that you have given.
:)
thanks.
 
why my &quot;usr/lib/sendmail&quot; can't send any email?
Well, it sounds like you are working with a WinOS and IIS for a web server. The '/usr/lib/sendmail' looks and smells like a UNIX flavored mail client. If you are trying to tweak an existing piece of code to get it to work on your system , it may be that the code was written to run on a UNIX box. If so, 'sendmail' may not exist on your box at all. I'm sure you can send mail on a Win box with Perl, but I have no idea what mail client you would use...... I just did a quick look and there is a module, &quot;Mail::pOP3Client&quot;, that looks like it will do what you want. You might take a look at that.

i wanted to upload something inside my server also.
See two FAQs in the Perl forum on file uploading.

HTH


keep the rudder amid ship and beware the odd typo
 
thanks for the reply.
and it's good to know how to download.
but, my problem is i dunno how to set the path of the uploaded file. no idea at all. u have any idea?
i am using iis. i am new to this iis. u have any fren who can tell me?
thanks a lot. :))

woody
 
Let me restate the situation and you tell me wether I understand what you are trying to do. There is client machine running browser that has a file that you want uploaded to the web server machine. You want to use a browser to upload the file to the web server and you are not clear about how set the path to save it on the server. Is that correct?
If so,.....
The following section is clipped from the FAQ and shows how to split the path which comes from the client box, create a new path, pop the file name off the end of the list, and glue the file name on the end of the new path string.

# with the path/filename from the client in $fileID,
@pathName = split(/\\/,$fileID);
# Read file from remote machine and write locally.
# You must change the following line to point to a
# dir on your machine that is writable by the web server daemon
$newFile ='/path/to/put/the/new/file/';

# add the upload filename to the new path
$newFile .= pop(@pathName);

I don't know how to tell you to figure out where you want to put the file. It just needs to be a place that IIS has the ability to write.

I hope this addresses you question.


keep the rudder amid ship and beware the odd typo
 
yes. u got my point. my problem is this one.

$newFile = '/path/to/put/the/new/file/';

I dunno how to figure out this &quot;/path/to/put/the/new/file/&quot;, really.
I mean, do i just put: &quot;or is there any special path, like &quot;/u/web/user/directory/subdir/filename.ext&quot;. thanks for your reply.
 
hi goBoating.
i am going to use Mail::Mailer for sending mail. I dunno what happened to my OS now. At first, I use ppm to install my dbi and dbd modules, it can run properly. But, now, when I tried to install the libnet and MailTool module, it has error. What I have done is like this:


C:\WINDOWS\ppm
PPM interactive shell (2.0) - type 'help' for avaiable commands.
PPM> install libnet
Install package 'libnet?' (y/N): y
Retrieving package 'libnet'...
HTTP POST failed: 500 (Server Error), in SOAP method call. Content of response: <html><head><title>Error</title></head><body>The specified procedure could not be found. </body></html> at C:/Perl/site/lib/PPM/SOAPClient.pm line 222
C:\WINDOWS


do u know what is happening? really need your reply soon. and sorry to throw u this trouble. hope to hear from u soon.
 
about the PATH......
The path you specify is a file system path not a url (no http:// stuff). On a UNIX box, it might look like /home/ On a win box it might look like c:\some\path\. I have no idea what your system dir structure looks like or where you SHOULD put you file. That requires that you think about it and make a decision.

about PPM....
I got that same error when trying to install a module here yesterday or the day before. I suspect the activeState server that serves the PPM requests was down. I'm still getting that error. I also see several references to this problem on some of ActiveState's email lists. However, I do not see a solution. I expect we just have to wait until the PPM server is back on line. An alternative route is to download the module from CPAN and follow the install instructions.

HTH


keep the rudder amid ship and beware the odd typo
 
alrite. thanks for your reply. it help me so much. i will try to do the upload thing first. thanks. will inform u if it's done already. thanks.
 
HELP!!!
problem in uploading:
i use the code below to upload...
it can open the file, it the sense that the file will appear in my server, but, there is no content there.
is there any mistake i have done?

===========================================================
open (SAVE,&quot;>$newpath&quot;);
my $total_size = '';
my $size='';
while ($size = read($FileName[$i-1],$data,1024))
{
print SAVE $data;
$total_size += $size;
if ($total_size > 100000)
{
close (SAVE);
unlink $newpath;
&error3;
exit;
}
}
close (SAVE);
===========================================================

the $newpath is the path in my own server, while the $FileName[$i-1] is the full file name of the remote area.
i am stuck now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top