Thread: libpq - Unhandled Exception - Executing Samples under win32

libpq - Unhandled Exception - Executing Samples under win32

From
"Eric Chapdelaine"
Date:
<div class="Section1"><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Hi,</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">I have downloaded the binairies no installer version of PostgreSql for windows. 
(postgresql-8.1.3-1-binaries-no-installer)</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial">I am able to init a database ( initdb), create users and create a database.</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">I am also able to use the psql executable shell too to Create Table, Insert record and Query
informationin my DB.</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Where it get complicated, is when I try to use the lib libpq and the samples that come with
it.</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">I am able to compile and link the sample, but when it comes to call the first DLL function, it
crasheswith an unhandled exception.</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Here is the source code where it fails with a context before and after:</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">[,,,]</span></font><p class="MsoNormal" style="text-indent:.5in"><i><font face="Arial"
size="2"><spanstyle="font-size:10.0pt;font-family:Arial;font-style:italic">conninfo = "dbname =
myDb";</span></font></i><pclass="MsoNormal"><i><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial;font-style:italic"> </span></font></i><p class="MsoNormal"><i><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial;font-style:italic">            /* Make a connection to the database */</span></font></i><p
class="MsoNormal"><i><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial;font-style:italic">            conn = PQconnectdb(conninfo);</span></font></i><p
class="MsoNormal"><i><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial;font-style:italic"> </span></font></i><p class="MsoNormal"><i><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial;font-style:italic">            /* Check to see that the backend connection was successfully made
*/</span></font></i><pclass="MsoNormal"><i><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial;font-style:italic">            if (PQstatus(conn) != CONNECTION_OK)</span></font></i><p
class="MsoNormal"><i><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial;font-style:italic">            {</span></font></i><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">[…]</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Does anyone knows how I can fix that problem ?</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial">Thank you.</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><strong><b><fontcolor="navy" face="Arial" size="2"><span
lang="EN-CA"style="font-size:10.0pt; 
font-family:Arial;color:navy">Eric </span></font></b></strong><b><font color="navy" face="Arial" size="2"><span
lang="EN-CA"style="font-size:10.0pt;font-family: 
Arial;color:navy;font-weight:bold"><br /></span></font></b><font color="navy" face="Arial" size="2"><span lang="EN-CA"
style="font-size:10.0pt;font-family:Arial;color:navy">SoftwareEngineer<br /></span></font><font color="navy"
face="ArialBlack" size="2"><span style="font-size:10.0pt;font-family:"Arial Black";color:navy">new</span></font><font
color="teal"face="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial; 
color:teal">logic</span></font><font color="navy" face="Arial" size="2"><span
style="font-size:10.0pt;font-family:Arial;color:navy">Canada<br /></span></font><font color="black" face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial;color:black"><a href="mailto:echapdel@newlogic.tv">echapdel@newlogic.tv</a></span></font><p
class="MsoNormal"><fontface="Times New Roman" size="3"><span style="font-size: 
12.0pt"> </span></font></div>