Hello, in the sql schema is the "Password" field "NOT NULL" .. so no check is required. Maybe you changed it?
Daniel Francisco Figueiredo Jr. schrieb: > 2009/3/17 Rodrigo Cuevas <[email protected]>: >> Hi Francisco, thank. >> > > Hi, Rodrigo! > You are welcome! > >> Other code with problem: >> >> MembershipUser user = Membership.GetUser("testuser"); //ok >> string pass = user.GetPassword(); //error >> >> Error: >> >> Unable to cast object of type 'System.DBNull' to type 'System.String'. >> >> D:\Sigem7\src\Npgsql2.0.4.src\src\Npgsql\NpgsqlDataReader.cs Line: 306 >> public override String GetString(Int32 i) >> Line 305: { >> Line 306: return (String) GetValue(i); //error >> Line 307: } >> >> Stack Trace: >> >> [InvalidCastException: Unable to cast object of type 'System.DBNull' to type >> 'System.String'.] >> Npgsql.NpgsqlDataReader.GetString(Int32 i) in >> D:\Sigem7\src\Npgsql2.0.4.src\src\Npgsql\NpgsqlDataReader.cs:306 >> NauckIT.PostgreSQLProvider.PgMembershipProvider.GetPassword(String >> username, String answer) in >> D:\Sigem7\src\NauckIT.PostgreSQLProvider-1.2.4.0\PgMembershipProvider.cs:782 >> >> Error Npgsql 2.0.4 or not ? >> > > In this case, this error is by design. > > Npgsql as well as other providers don't handle null values on their > get* methods. > You should call IsDBNull to test this. > > http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.getint32.aspx > > "No conversions are performed; therefore, the data retrieved must > already be a 32-bit signed integer. > > Call IsDBNull to check for null values before calling this method." > > I hope it helps. > > > _______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
