probably the placehoder answer would work. But other than that, I think this
would probably work:
my $sth = $dbh->prepare("insert into emails values ('$addr')")
|| die "Can't prepare statement: $DBI::errstr";
embedding the value inside of double quotes or
my $sth = $dbh->prepare("insert into emails values ('" . $addr . "')")
|| die "Can't prepare statement: $DBI::errstr";
quoting the string with double qoutes and concatentating the single quotes
with the value contained in $addr, resulting in the correct statement...
more of a perl problem than a DBI problem.
Hope this helps.
H
> -----Original Message-----
> From: nayeem [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, August 12, 2001 11:26 AM
> To: [EMAIL PROTECTED]
> Subject: Cannot Insert into SQL Server
>
>
> Can Anybody help me to insert the records in Sql Server.
> Actually this code
> is working but inserting $addr as value instead of variable $addr
> 's value
> that is abc, so is there any solution to add the variable values...
>
> use DBI;
> my $addr ='abc';
> my $dbh = DBI->connect("dbi:ODBC:email", "sa", "zajilpass")
> || die "Can't connect to $data_source: $DBI::errstr";
> my $sth = $dbh->prepare( q{
> insert into emails values ('$addr')
> }) || die "Can't prepare statement: $DBI::errstr";
> my $rc = $sth->execute
> || die "Can't execute statement: $DBI::errstr";
>
>
> check this code and please advice me.
>
> Thanks,
> Nayeem.
>
>
>
>