?
Solved

insert into microsoft sql database

Posted on 2005-04-04
4
Medium Priority
?
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 84

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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

752 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