Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

insert into microsoft sql database

Posted on 2005-04-04
4
Medium Priority
?
202 Views
Last Modified: 2010-03-05
I'm having problems inserting into a remote database.  

my code:

use Win32::ODBC;

my $DSN = "DSN=mydsn;UID=myid;PWD=password;";
my $connection = new Win32::ODBC($DSN);
$SQL = "INSERT INTO tblUploadLog \(ID\, CreateDateTime\, Status\) VALUES \(\'101\', \'1\/1\/2005\', \'Problem\')";

Not sure what's wrong.  

I ran this from a command prompt and there aren't any error messages.

I ran the same sql statement on the remote database manually with enterprise manager and it works.
0
Comment
Question by:tedhyu
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 1000 total points
ID: 13700696
use Win32::ODBC;

my $DSN = "DSN=mydsn;UID=myid;PWD=password;";
my $connection = new Win32::ODBC($DSN) or die " Error connecting to $DSN\n Error: " . Win32::ODBC::Error();

$SQL = "INSERT INTO tblUploadLog (ID, CreateDateTime, Status) VALUES ('101', '1/1/2005', 'Problem')";

if( $connection>Sql($SQL) ){
    print "SQL failed.\n";
    print "Error: " . $connection->Error() . "\n";
    $connection->Close();
    exit;
}
0
 

Author Comment

by:tedhyu
ID: 13700866
use Win32::ODBC;

my $DSN = "DSN=mydsn;UID=myid;PWD=password;";
my $connection = new Win32::ODBC($DSN) or die " Error connecting to $DSN\n Error: " . Win32::ODBC::Error();

$SQL = "INSERT INTO tblUploadLog (ID, CreateDateTime, Status) VALUES ('101', '1/1/2005', 'Problem')";

if( $connection>Sql($SQL) ){
    print "SQL failed.\n";
    print "Error: " . $connection->Error() . "\n";
    $connection->Close();
    exit;
}

->  Same result with this code.  None of the connection error messages came up when i ran it through command prompt.


0
 
LVL 18

Expert Comment

by:kandura
ID: 13701433
what errors do you get?
0
 

Author Comment

by:tedhyu
ID: 13701521
I got it to work with some tweaking.  
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question