Thread: VB.NET web applications accessing PostgresSql through ODBC
I've just started working with PostgresSQL. Currently, we are using version 8.2 on a Windows XP platform for both the PostgresDB and all other application files. I am trying to estabish a connection to the database using ODBC (PostgreSQL Unicode driver 8.02.02.00) within a VB.Net application.When I make the connection as a desktop application, I am able to successfully access the database. However,when I attempt to make the connection through a VB.Net web application, I am getting the following error: ERROR [28000] Communication error during authentication; Error while reading from the socket. I've tried using both direct ODBC functions and ADO objects, with similar problems (i.e. it functions in a desktop environment,but not through a web environment). An example of my code to access the database is as follows: Dim szConnect As String = "DSN=mydsnname;UID=myuid;PWD=******" Dim cnDB As New Odbc.OdbcConnection(szConnect) cnDB.Open() ' <--- this is where the code fails Dim dsDB As New DataSet Dim adDB As New Odbc.OdbcDataAdapter Dim cbDB As New Odbc.OdbcCommandBuilder(adDB) adDB.SelectCommand = New Odbc.OdbcCommand("Select * from mytable", cnDB) adDB.Fill(dsDB) Any idea why the failure occurs when doing web applications? Is there some set of permissions I have to give to the web serverprocess or some other code in order to give it permission to run ODBC applications?
> Any idea why the failure occurs when doing web applications? Is there some set of permissions I > have to give to the web server process or some other code in order to give it permission to run > ODBC applications? Not too sure whay you are getting this error, if you don't get the answer you are looking for on this list you will probably get your answer on the pg_odbc list for sure. Just curious, why not use the .net provider for postgres rather than odbc since you are already programming in .net? http://pgfoundry.org/projects/npgsql Regards, Richard Broersma Jr.
> I've just started working with PostgresSQL. > Currently, we are using version 8.2 on a Windows XP > platform for both the Postgres DB and all other > application files. > > I am trying to estabish a connection to the database > using ODBC (PostgreSQL Unicode driver 8.02.02.00) > within a VB.Net application. Allan, i don't know if it is an issue or not, but i recall that the odbc drivers for pgsql are gpl. if i'm right, i think this might mean your whole application may have to be gpl if you use them. i'm not 100% certain and i don't evenknow if it is an issue for you, however, i thought i'd chime in so you can follow up on it *if* it is an issue. good luck. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
<operationsengineer1@yahoo.com> writes: > Allan, i don't know if it is an issue or not, but i > recall that the odbc drivers for pgsql are gpl. No, they're LGPL. unixODBC is GPL, but I don't think a Windows user cares about that. regards, tom lane
> <operationsengineer1@yahoo.com> writes: > > Allan, i don't know if it is an issue or not, but > i > > recall that the odbc drivers for pgsql are gpl. > > No, they're LGPL. > > unixODBC is GPL, but I don't think a Windows user > cares about that. > > regards, tom lane Thanks, Tom. i didn't mean to cause any confusion - i saw this in the docs and i guess the "unix" part didn't register in my weary head. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Use the .net provider as Richard mentioned. http://pgfoundry.org/projects/npgsql The documentation is quite good which shows you how to connect to the db etc. in .NET. All you need to do is copy the npgsql.dll file into your apps bin folder. For example your code would look something like... Dim szConnect As String = "DSN=mydsnname;UID=myuid;PWD=******" Dim cnDB As New PgSqlConnection(szConnect) cnDB.Open() ' <--- this is where the code fails Dim dsDB As New DataSet Dim adDB As New PgSqlDataAdapter Dim cbDB As New PgSqlCommandBuilder(adDB) adDB.SelectCommand = New PgSqlCommand("Select * from mytable", cnDB) adDB.Fill(dsDB) If you have any other issues let us know. Been using PostGreSQL with .NET extensively lately and it's a breeze :) -----Original Message----- From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Allan Sullivan Sent: Friday, December 15, 2006 10:58 PM To: pgsql-novice@postgresql.org Subject: [NOVICE] VB.NET web applications accessing PostgresSql through ODBC I've just started working with PostgresSQL. Currently, we are using version 8.2 on a Windows XP platform for both the Postgres DB and all other application files. I am trying to estabish a connection to the database using ODBC (PostgreSQL Unicode driver 8.02.02.00) within a VB.Net application. When I make the connection as a desktop application, I am able to successfully access the database. However, when I attempt to make the connection through a VB.Net web application, I am getting the following error: ERROR [28000] Communication error during authentication; Error while reading from the socket. I've tried using both direct ODBC functions and ADO objects, with similar problems (i.e. it functions in a desktop environment, but not through a web environment). An example of my code to access the database is as follows: Dim szConnect As String = "DSN=mydsnname;UID=myuid;PWD=******" Dim cnDB As New Odbc.OdbcConnection(szConnect) cnDB.Open() ' <--- this is where the code fails Dim dsDB As New DataSet Dim adDB As New Odbc.OdbcDataAdapter Dim cbDB As New Odbc.OdbcCommandBuilder(adDB) adDB.SelectCommand = New Odbc.OdbcCommand("Select * from mytable", cnDB) adDB.Fill(dsDB) Any idea why the failure occurs when doing web applications? Is there some set of permissions I have to give to the web server process or some other code in order to give it permission to run ODBC applications? ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly