473,598 Members | 3,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Internal Server Error in connecting Postgresql Server

3 New Member
Hello,

I wrote C program for connecting to postgresSQL server to retrieve data from the postgres database. The program is:

#include <stdio.h>
#include <stdlib.h>
#include "libpq-fe.h"

int
Search(inStruct Sentries)
{
char state_code[3];
char query_string[256];
PGconn *conn;
PGresult *res;
int i;

conn = PQconnectdb("ho st=127.0.0.1 dbname=ontology user=postgres password=postgr es port=5432");

if (PQstatus(conn) == CONNECTION_BAD)
{
printf("Content-type: text/html%c%c",10,10 );fflush(stdout );
printf("<html>" );
printf("<body background=\"%s/background.gif\ ">", webPath);
fprintf(stderr, "Connection to database failed.\n");
fprintf(stderr, "%s", PQerrorMessage( conn));
exit(1);
printf("</body></html>");
}


sprintf(query_s tring,
"SELECT term_name \
FROM term \
WHERE term_id = '%s'", Sentries->entries[1].val);

res = PQexec(conn, query_string);

if (PQresultStatus (res) != PGRES_TUPLES_OK )
{
printf("Content-type: text/html%c%c",10,10 );fflush(stdout );
printf("<html>" );
printf("<body background=\"%s/background.gif\ ">", webPath);
fprintf(stderr, "SELECT query failed.\n");
PQclear(res);
PQfinish(conn);
exit(1);
printf("</body></html>");
}

for (i = 0; i < PQntuples(res); i++)
printf("%s\n", PQgetvalue(res, i, 0));
printf("Content-type: text/html%c%c",10,10 );fflush(stdout );
printf("<html>" );
printf("<body background=\"%s/background.gif\ ">", webPath);
printf("<br><br ><font>Term Name: </font><font color=#FF0000>% s</font>",res);
printf("</body></html>");

PQclear(res);

PQfinish(conn);

return 0;
}

When I run this program, I got the Internal Server Error. What could be the problem here? Can anyone help me to solve this problem.
Really appreciate for the helping hands.

With Regards,
SYT
Mar 11 '08 #1
0 2775

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1228
by: Terry Ladouceur | last post by:
I have installed VB.NET 2003 on my machine. Whenever I write a web service or web page of any type that uses ADO to connect to a SQL Database I get a HTTP Error 500 Internal Server Error. I have tried connecting to local SQL, Remote SQL, have the service run on a personal web server and a remote web server and I get the same thing everytime. Any assistance would be greatly appreciated. Thanks. Terry
0
3843
by: Bill J. | last post by:
I have to update a PostgreSQL linked server through MSSQL2K. I first configured the connection with ODBC as follows and I can do queries with no problem: EXEC sp_droplinkedsrvlogin @rmtsrvname = 'PostgreSQL', @locallogin = NULL GO EXEC sp_DropServer 'PostgreSQL' GO
0
2165
by: Bill J. | last post by:
I have to update a PostgreSQL linked server through MSSQL2K. I first configured the connection with ODBC as follows and I can do queries with no problem: EXEC sp_droplinkedsrvlogin @rmtsrvname = 'PostgreSQL', @locallogin = NULL GO EXEC sp_DropServer 'PostgreSQL' GO
2
1787
by: Jeff | last post by:
I have the following packages installed on my system: libpq3: 7.3.2r1-5 python-pygresql: 7.3.2r1-5 postgresql: 7.2.1-2woody2 postgresql-client: 7.2.1-2woody2 In my application, which is written in python, I get a "server closed the connection unexpectedly" exception after executing a few sql commands. I print each query before I execute it (debugging) so I tried executing the
12
2765
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed both the iis and sql server in a single machine. Not too long ago, the machine had some hardware problems, and management has decided to purchase new servers, for both asp.net and sql server.
2
2247
by: Kevin R | last post by:
I'm trying to get asp.net 1.1 running on my home PC. When I try creating a new ASP.NET Web Application in 'Visual Studio .NET 2003' I get the following error: "Visual Studio .NET has detected that the specified Web server is not running ASP.NET version 1.1. You will be unable to run ASP.NET Web applications or services" Thanks for any help in advance. Kevin ===============================
2
7254
by: Andy Chen | last post by:
Hi, When I am using the fowllowing code to open page http://spaces.msn.com/members/mailcall/ .... try{ string url = http://spaces.msn.com/members/mailcall/; HttpWebRequest httpReq = null; HttpWebResponse httpResp = null; httpReq = (HttpWebRequest)WebRequest.Create(url);
14
7021
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that sql server resides on is not reachable. The error is different depending on the connection string that I use. If I use the following connection string: "server=192.1.1.1; Initial Catalog=master; uid=The_User; password=The_Password; Connect...
2
5267
by: student2 | last post by:
Hi, I'm a student looking for any recommendation to finding a solution to the following problem. (Hope I'm posting in the correct 'section' of the forum, since my error says both IIS and ASP) I'm not quite sure if it is an IIS problem or an ASP or either :S I'm running IIS on my WIndows XP Pro OS. I'm connecting an Access database (.mdb file) to Dreamweaver CS4. I've made the connection with the following string ...
0
7985
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8389
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8263
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5848
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5438
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1503
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1246
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.