aspnet_Membership_GetPassword and aspnet_Membership_GetUserByName return "Error converting data type varchar to datetime"

I have an asp:PasswordRecovery control that stopped responding to "Forgot your password". I enter a valid user name (I know it's valid because I used it to login) and press next (this is normally where one gets their password mailed to them) and I get the error "Your attempt to retrieve your password was not successful, please try again".

So I fired up SQL profiler and found that the code was calling first aspnet_Membership_GetUserByName() and then aspnet_Membership_GetPassword(). I tried the same calls in SQL Query and I got the error: "Error converting data type varchar to datetime". The problem turned out to be that GetUser() in SQLMembershipProvider.cs was passing the following parameter: @CurrentTimeUtc='2009-03-18 17:57:48.0770000'. The problem is in the extra zeros on the right. If I take them out, the query succeeds.

Does anyone know what's going on? This is all Microsoft provider code and Microsoft ASP (asp:PasswordRecovery) code that has not changed as far as I know. I'm running .Net 3.5 on the web site.

3/18/2009 11:25:03 PM 27051 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 57

Hi harafeh,

Could you please show us the SQL query in SQL Server Profiler? Please show us more details so that we can help you better.


David Qian
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
3/20/2009 7:11:36 AM

Not sure if this helps but i had the same error when running Membership.CreateUser.  I was only passing username and password, and it gave me the abovce error.  I then changed it to also provide the email address (I use email address as username so username and email are always the same), and it worked.

As i said not sure if this helps, but it might help track down where the issue is comming from.

BTW, im now having a similar problem when calling Membership.ValidateUser and thus 'aspnet_Membership_GetPasswordWithFormat'.  The only thing i've done differently is install SQL2008 and attached my sql2005 database.  I'm debugging so i'll let you know if i find anything


UPDATE: Turns out the issue causing the error was something else, BUT this is what was throwing me:  Profiling with SQL2008 must assume that dates passed into procedures which are declared with datetime are interpreted as datetime2 by default i.e.:

(Profiler output snip) ,@CurrentTimeUtc='2009-04-15 06:40:17.5730000'

So when i copy and paste into sql analyser it gives the "Error converting data type varchar to datetime" error because the procedure is declared with: '@CurrentTimeUtc datetime,' and thus causing an overflow as datetime2 is more precise (up to 7 decimal places compared to 3 for datetime).  So the error is only caused by a difference in interpretation by profiler 2008 and procedures declares declared with 2005 datetime object.  The initial issue probobly has nothing to do with the varchar conversion error (at least in my case)!!

4/15/2009 4:31:20 AM

My real problem turned out to be that when we first created our membership provider we chose hashed passwords. Later on, we changed to encrypted passwords. We thought we recreated all the old accounts but this one user account, at least, was not so it kept its hashed password. So even though that user account can do just about anything, changing password was not one of them. The error message from the membership provider was completely useless.

To add insult to injury, the SQL shown by the profiler was not what exactly what the provider generated. It turns out that *all* SQL statements generated by the provider had the same fake problem. I don't know what the exact SQL generated looks like but it all executes correctly and the error shown above is a red herring. I'm just guessing here, but I think the profiler was reformatting the sql and adding the extra zeros to the end.

To solve the "cannot change password" problem, we simply recreated that user account so it now has the correct type of password (encypted instead of hashed).

Many thanks to those who tried to help.

4/15/2009 4:22:35 PM

Similar Artilces:

Error:"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."
I still don't know what is happening with my application. I used before in another page the formview control and I didn't have the out of range Date error. It was normally. But now, I'm doing everything manually and I don't know why, but I'm with this problem. I need to safe this problem today... Here go my code! The error occurs here: (It's the Sub that Insert data inside of the database(SQLServer)Protected Sub Gravar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim SQL As String = "Update RECEBER SET  EMISSAO = '" & CType(tbDataEmissao.Text, Date) & "', VENCIME...

Whan can i do? make "string" data type convert to "window" data type, and use a "window" name to get it ancestor "window name", thanks! i use pb5
Rich, With a string window name, you can open a window of that type if you need to. You could, of course, query that window object for any attributes. Another option is to use the LibraryExport function to export the definition of the window which is specified by the string. You can then parse the resulting file to get information on the ancestor object. HTH Sanjiv. "Rich" <> wrote in message > > > ...

what is the diference between "varchar" and "char" data type?
Is the same or what? SOTOS wrote in message ... >Is the same or what? Depends on the database server (and the NULL option, for that matter). In general, char is static length while varchar is dynamic length. BUT, it depends on your database server. Your best source of information is your database vendor's manuals. On Fri, 19 May 2000 13:37:53 +0300, "SOTOS" <> wrote: >Is the same or what? > > ...

SQL Server Error: "Arithmetic overflow error converting numeric to data type numeric"
I'm still quite new to SQL, and so I may be missing something quite obvious. Apologies in advance if that's the case. I've included my query at the bottom of the message as it is quite long; my problem is that I get "Arithmetic overflow error converting numeric to data type numeric" when the first parameter to my COALESCE calls is not NULL. That is, the COALESCEs and the query work as I expect when SUM(cust_vw_actual.Actual) is NULL (they return 0.00), but if it isn't I get the error. I am also getting "Warning: Null value eliminated from aggregate.&...

"Error converting data type nvarchar to numeric."
Hi  Im using the <asp:SqlDataSource to display a table in a datagrid. The data grid has AutoGenerateEditButton="True". I’m using this update command in the QslDataSource: UpdateCommand="UPDATE ShoeSize SET US = @US, Eur = @Eur, CM = @CM, Quant = @Quant, id = @id, UK = @UK  FROM ShoeSize WHERE IDroll = @IDroll" All the cells in the table is decimal(6,1) except ID, quant and IDroll witch are ints. But when I press update I get this error message: "Error converting data type nvarchar to numeric." I unde...

Declaring data table "Value of type ..datatable" cannot be converted to "...datatable".
 Hi Guys, The subject of the post clarifies my problem. Do you have any ideas why that is the case? I have done it the same way in a previous project (ok... the difference there was an input paramters for the method) and it worked great.   Thanks,polynaux  Dim dt as LocationsDataTable Dim dr as LocationsDataRow ?  -- "Mark As Answer" if my reply helped you --  hi gunteman, thats how I have done it previously   'Load data into textboxes Dim tPAttribute As New DateSet02_SelectAll_InpusIsATableAdap...

Getting Server Error "Syntax error converting the nvarchar value 'Sonoma' to a column of data type int."
Hi, all I'm getting this error at runtime when my page tries to populate a datagrid. Here's the relevant code. First, the user selects his choice from a dropdownlist, populated with a sqldatasource control on the aspx side:<asp:SqlDataSource ID="sqlDataSourceCompany" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [PayrollCompanyID], [DisplayName] FROM [rsrc_PayrollCompany] ORDER BY [DisplayName]"> </asp:SqlDataSource>  And the dropdown list's code:<asp:DropDownList ID="ddlPayrol...

How to Convert "string" to "DateTime"
hi , i have a problem i have an textarea that i want to convert to DateTime format (dd/MM/yyyy) . the data in the textarea is (dd/MM/yyyy for example 21/12/2005). i need it to add this data in sql server , in smalldatetime formation colum . plz help.     Wouldn't you just use: DateTime dt1 = DateTime.Parse( stringToParse, formatProvider, styles) This doesn't quite seem like a SQL Server question ... but in ASP.NET you can convert a string to a date using the DateTime.Parse(string) method. Then you could use this as the value of a parameter to a stored procedure with t...

Converting a type "void" to a type "System.Drawing.Image"
I'm trying to input a thumbnail image in to a a image control.  I keep getting the same error "Cannot implicitly convert type void to type System.Drawing.Image".  I'm coding in C# I've been looking throught object browser to try to find a way to convert the type but it is not working. can anyone help   Hi, could it be that method has incorrect return type? is it your own method raising it? Post some code.Thanks,Teemu KeiskiFinland, EU Here is the code:  The error is commented.  public static bool ThumbNailCallBack() { return false; } public s...

"data only" "log only" data and log"
i altered the db to include 1 gb. however the fragment was created "data and log". what should have i done to create a 'data only' fragment? melanie wrote: > i altered the db to include 1 gb. > however the fragment was created "data and log". > > what should have i done to create a 'data only' fragment? I believe I'm correct in saying that if your database has data and log on separate devices the alter database command will assume you're adding to "data" unless you specify otherwise by using the "log on&q...

Web Methodst that returns DataTable gives me exception error " "circular reference was detected while serializing an object of type""
Hello, I am getting this error "circular reference was detected while serializing an object of type". The Method GetRecords() is a function that returns DataTable type.. It happens the same thing when i return DataSet as well. Any help? Thanks    function GetStatusRecord() {   // Invoke the Echo method on the server.PageMethods.GetRecords('1', onComplete);  debugger; // Callback function.function onComplete(result) { // Display the echoed string. alert(result); }   return false }   The latest version of Ajax no lo...

error "Failed to get datetime data" using 1.0.1
Hello, My situation: I have a vs2005 project with version 1.0.1 (build 5502), database is asa10. When my regional settings are Dutch(Belgium) I have no problems at all. When the settings are Italian(Italy) I get a "Failed to get datetime" error when I retrieve when my data contains dates. When the date fields are not filled in then I do not get the error. A date of '2008-1-1 08:00:00' also gives errors. When I try to retrieve the same data in the datawindow painter I also get no error. Can anyone help me? Greetings, Mich=E8le 2.5 is now th...

VB.NET "cannot convert type A into type A" driving me crazy!
Hi, in the aspx I have declared a structure "InsFlds" as follows: Structure InsFlds Dim Value AS String Dim CtlName AS String Dim CtlType AS Integer End StructureThen I'm setting up an array to hold some of these:DIM InsValDefaults(26)AS InsFlds And in the next lines I am checking a session-variable and, if it exists, assign it to that array:IF Session("InsValDefaults") IsNot Nothing Then SiAuto.Main.LogObject("Session(InsValDefaults)",Session("InsValDefaults")) InsValDefaults = Session("InsValDefaults") ...

Why do I have to type "data.DataTable" instead of "DataTable"?
I've been developing c# projects and now need to develope one in vb.  (dont ask why) All I wan to do is decalre dim data as DataTable but I'be being forced to decalre as dim data as data.dataTable?   Why is it so????       Do you have a using(C#)/Imports(VB) statement for the System.Data namespace in your file? The new refactoring tools should give you the option to add that if you delete the "Data." portion of that declaration (assuming you have the refactoring support for VB installed).Andrew L. Van VB is also case insensitive, so y...

Web resources about - aspnet_Membership_GetPassword and aspnet_Membership_GetUserByName return "Error converting data type varchar to datetime" -

Resources last updated: 1/15/2016 2:54:53 AM