johnmemor
asked on
MS SQL in Perl ?
Here is my "select" part :
#!C:\perl\bin\perl
use DBI;
$dbHandle = (DBI->connect('DBI:ADO:DSN ', 'sa', ''));
$sql = "SELECT * FROM Test";
$statementHandle = $dbHandle->prepare($sql);
$statementHandle->execute( ) || die $statementHandle->errstr;
while (($cat1) = $statementHandle->fetchrow _array )
{
print $cat1."\n";
}
Above script works fine. I just wonder how can I insert some value into the table ?
May I have some example script for insert ?
#!C:\perl\bin\perl
use DBI;
$dbHandle = (DBI->connect('DBI:ADO:DSN
$sql = "SELECT * FROM Test";
$statementHandle = $dbHandle->prepare($sql);
$statementHandle->execute(
while (($cat1) = $statementHandle->fetchrow
{
print $cat1."\n";
}
Above script works fine. I just wonder how can I insert some value into the table ?
May I have some example script for insert ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How can I get the row count ?
This is what I have :
$rowCount = $dbh->do($sql);
print $rowCount."\n";
and I got -1, I have more than 1 record in the table.
This is what I have :
$rowCount = $dbh->do($sql);
print $rowCount."\n";
and I got -1, I have more than 1 record in the table.
ASKER
#!C:\perl\bin\perl
use DBI;
$dbHandle = (DBI->connect('DBI:ADO:DSN
$sql = "insert into Test (name) values(\"some_value\")";
$statementHandle = $dbHandle->prepare($sql);
$statementHandle->execute(
I got error after execution.