<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
I'm going to migrate a very very old Microsoft Access application,
during a certain time I need ton send and read data in MS Access.<br>
I've compiled this small script for windows, and it run on same
machine as MS Access and this script listen on port 2000<br>
<br>
use strict;<br>
my @tableau;<br>
$tableau[0] ='--localport=2000';<br>
$tableau[1]='--debug';<br>
require DBI::ProxyServer;<br>
delete $ENV{IFS};<br>
delete $ENV{CDPATH};<br>
delete $ENV{ENV};<br>
delete $ENV{BASH_ENV};<br>
DBI::ProxyServer::main(@tableau);<br>
exit(0);<br>
<br>
my connection is here<br>
<pre wrap="">my $dsn = "DBI:Proxy:hostname=$IP;port=$PORT;dsn=DBI:ODBC:$ODBC";
my $dbh = DBI->connect($dsn, "", "") || die "Erreur de connexion à la base";</pre>
and <br>
my $sth = $dbh->prepare($sql);<br>
$sth->execute();<br>
<br>
<br>
<br>
I tried to configure with config.yaml<br>
Plugins:<br>
Database:<br>
connections:<br>
Access:<br>
driver:
'Proxy:hostname=192.168.0.19;port=2000;dsn=DBI:ODBC:myodbconnection'<br>
<br>
<br>
connection seem to be ok <br>
<br>
how I can call db handle ?<br>
<br>
if I use something like <br>
<br>
my $line = database('Access')->quick_select('CommandeBNP',
{Ckey => params->{Ckey} } );<br>
<br>
SQL language from <code class="pl plain"><a
href="https://metacpan.org/module/Dancer::Plugin::Database">Dancer::Plugin::Database</a>;</code>
is wrong and Access stop this this error<br>
<br>
<br>
<br>
<br>
Thu Apr 11 15:08:55 2013] [error] [client 192.168.0.19]
\tDancer::Object::new('Dancer::Error', 'code', 500, 'title',
'Runtime Error', 'message', 'DBD::Proxy::st execute failed: Server
returned error: Failed to execute method CallMethod: DBD::ODBC::st
execute failed: [Microsoft][Pilote ODBC Microsoft Access] Erreur de
syntaxe (opM-irateur absent) dans l\\'expression
\\'NumContrat=Pa_RaM000 AND CodeClient=Pa_RaM001 \\'. (SQL-42000) at
/<C:\\Users\\Hugues\\Desktop\\AccessProxy.exe>DBI/ProxyServer.pm
line 341.^J', 'exception', 'DBD::Proxy::st execute failed: Server
returned error: Failed to execute method CallMethod: DBD::ODBC::st
execute failed: [Microsoft][Pilote ODBC Microsoft Access] <br>
<br>
<br>
<div class="moz-cite-prefix">Le 11/04/2013 14:27, Stefan Hornburg
(Racke) a écrit :<br>
</div>
<blockquote cite="mid:5166AC48.20706@linuxia.de" type="cite">
<pre wrap="">On 04/11/2013 02:14 PM, Hugues Max wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hello
I need to write a Dancer Application where I need to connect to Microsoft Access 97/2003 Database... :'(
I use DBI::Proxy
my $dsn = "DBI:Proxy:hostname=$IP;port=$PORT;dsn=DBI:ODBC:$ODBC";
my $dbh = DBI->connect($dsn, "", "") || die "Erreur de connexion à la base";
$dbh->{AutoCommit} = 1;
$dbh->{RaiseError} = 1;
it's not fast but it's works.
I tried to use Dancer::Plugin::Database but Microsoft SQL is not compatible ( Limit doesn't exist, this is TOP etc.. )
</pre>
</blockquote>
<pre wrap="">
You could still use Dancer::Plugin::Database for setting up and maintaining the database connection.
</pre>
<blockquote type="cite">
<pre wrap="">
my %ClientParc ;
$sql =q/SELECT Spécifique, Quantité, PrixMaintenance FROM ClientParc WHERE NumContrat=? AND CodeClient=?/;
$stha = $dbha->prepare($sql);
$stha->execute($NumContrat, $CodeClient );
while (my ($Specifique, $Quantite, $PrixMaintenance) = $stha->fetchrow_array()) {
$ClientParc{$Specifique} = { Specifique => $Specifique, Quantite => $Quantite, PrixMaintenance => $PrixMaintenance }
}
I create a hash %ClientParc and I send it to TTK
and I do
return template '/echeancier' => {
ClientParc => \%ClientParc
}
in my view
[% FOREACH s IN ClientParc.values -%]
[%- IF loop.first %]
<div class="span5"> [% s.Quantite %] [% s.Specifique %] </div>
[% ELSE %]
<div class="span5 offset5"> [% s.Quantite %] [% s.Specifique %] </div>
[% END %]
[% END %]
And it's works but
I got 2 questions
1 ) are they a better solution ?
</pre>
</blockquote>
<pre wrap="">
Obviously make a better choice on your database backend :-).
</pre>
<blockquote type="cite">
<pre wrap="">2) for each page , I need to connect to MS Access proxy and this is slow ( 2 ou 3 sec for connection, but after queries are enough fast ),
are they a solution to maintain a DB connection ?
</pre>
</blockquote>
<pre wrap="">
How and where do you connect?
Regards
        Racke
</pre>
</blockquote>
<br>
</body>
</html>