View Single Post
  #6 (permalink)  
Old January 23rd, 2007, 12:02 PM
gbianchi gbianchi is offline
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

you need to read the password for each record..

doing this
Code:
    dr.Read()
    Dim strPWEncoded As String = FormsAuthentication.HashPasswordForStoringInConfigFile(dr("password"), "SHA1")
    dr.Close()
will only read the password for the first record

you have to change your logic to something like this:

Code:
    Dim strPW As String = ""
    Dim dr As SqlDataReader
    Dim strSQL3 As String
    Dim sql As String = "Select password from members_bkp"
    Dim cnn As New SqlClient.SqlConnection(strConnection)
    cnn.Open()
    strSQL3 = "UPDATE members_bkp set password=@pwd"
    Cmd = New SqlCommand(strSQL3, cnn)
    Dim Cmd As New SqlCommand(Sql, cnn)
    dr = Cmd.ExecuteReader()
    do while dr.Read()
        Dim strPWEncoded As String = FormsAuthentication.HashPasswordForStoringInConfigFile(dr("password"), "SHA1")
        Cmd.Parameters.Add(New SqlParameter("@pwd", strPWEncoded))
        Cmd.ExecuteNonQuery()
    end while
    dr.Close()
NOTE: the above will not work ok because the update command needs a where clause to tell it which record to update.. you will have to add it to the update command because I don't know your tables...






HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
Reply With Quote