Monday, May 18, 2009

Adding Personalization to ASP.NET with PostGIS (PostgreSql)

Next step - adding personalization to the web site using Postgresql.

Very easy, as well as documented.

Just go to:

http://dev.nauck-it.de/aspsqlprovider/

and follow the directions.

One thing not mentioned is the PostgreSQL encoding of the database when you create it. I used the default Win1252, which seemed to work fine.

I created the database, ran the SQL script to create the tables, and added/modified the web.config file.

Created a asp.net web form with a login control, ran it, but it didn't work. Got:

at NauckIT.PostgreSQLProvider.PgMembershipProvider.ValidateUser(String username, String password) in C:\Users\Daniel Nauck\Documents\Visual Studio 2008\Projects\PostgreSQLProvider\PgMembershipProvider.cs:line 1229 at System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e)

Well, that was a bit disconcerting. So, looked at the Immediate window in VS2008, for more info, and saw:

Npgsql.NpgsqlException:
syntax error at or near "("
Severity: ERROR
Code: 42601
at Npgsql.NpgsqlState.d__a.MoveNext()
at Npgsql.NpgsqlState.IterateThroughAllResponses(IEnumerable`1 ienum)
at Npgsql.NpgsqlState.ProcessBackendResponses(NpgsqlConnector context)
at Npgsql.NpgsqlReadyState.Flush(NpgsqlConnector context)
at Npgsql.NpgsqlConnector.Flush()
at Npgsql.NpgsqlCommand.Prepare()
at NauckIT.PostgreSQLProvider.PgMembershipProvider.ValidateUser(String username, String password) in C:\Users\Daniel Nauck\Documents\Visual Studio 2008\Projects\PostgreSQLProvider\PgMembershipProvider.cs:line 1210
A first chance exception of type 'System.Configuration.Provider.ProviderException' occurred in NauckIT.PostgreSQLProvider.DLL

Not too helpful...

Then tried various things, made sure the uid and password was ok, changed the name of the application to the name of my project, etc. These had no effect.

Then, did a get of the latest Nauck from SVN and added to my solution. Then it started working. Perhaps the release 1.240 is a little bogus? Anyway, now it works. Awesome.

1 comment:

Francisco Junior said...

Hi!

I'm glad to hear your got it working.
The problem you were facing was the ticket 11 of asp.net provider. In fact, it is caused by a regression of Npgsql which we fixed in 2.0.5. When you get the latest asp.net provider it already contains the 2.0.5 version.