Author |
Topic |
|
kentk
Starting Member
USA
30 Posts |
Posted - 08 June 2006 : 11:29:02
|
I am creating a custom profile provider, the provider inherits from the profileProvider class. In the below function there is a context object, I use the context("User_Name") to create my sql parameter. If I set a breakpoint on the line ".Parameters.AddWithValue("@M_NAME", context("User_Name"))" the context("User_Name") will have a value, the value of my login name when it hits the breakpoint. If I step to the next line it "seems" to lose it value. Is it some kinda timing issue or something else I'm not setting?
Any help would be greatly appreciated.
Thanks
Public Overrides Function GetPropertyValues(ByVal context As System.Configuration.SettingsContext, ByVal collection As System.Configuration.SettingsPropertyCollection) As System.Configuration.SettingsPropertyValueCollection Dim values As New SettingsPropertyValueCollection Dim conn As New SqlConnection(connStr) Dim strSQL As String = "SELECT * FROM FORUM_MEMBERS WHERE M_NAME = @M_NAME" Dim cmd As SqlCommand Dim setProperty As SettingsProperty Dim reader As SqlDataReader
Try cmd = New SqlCommand(strsql, conn)
With cmd .CommandType = Data.CommandType.Text .Parameters.AddWithValue("@M_NAME", context("User_Name"))
conn.Open()
reader = .ExecuteReader(Data.CommandBehavior.SingleRow)
End With
For Each setProperty In collection Dim setValue As New SettingsPropertyValue(setProperty) If reader.HasRows Then setValue.PropertyValue = reader(setProperty.Name) values.Add(setValue) End If
Next
Return values Catch ex As Exception Throw ex Finally conn.Close() cmd.Dispose() End Try End Function |
Kent
"Wakey, wakey, hands off snakey!" |
|
kentk
Starting Member
USA
30 Posts |
Posted - 08 June 2006 : 13:16:30
|
Solved my own problem,
context("User_Name") should be context("UserName")
Function should look like this: Public Overrides Function GetPropertyValues(ByVal context As System.Configuration.SettingsContext, ByVal collection As System.Configuration.SettingsPropertyCollection) As System.Configuration.SettingsPropertyValueCollection Dim values As New SettingsPropertyValueCollection Dim conn As New SqlConnection(connStr) Dim strSQL As String = "SELECT * FROM FORUM_MEMBERS WHERE M_NAME = @M_NAME" Dim cmd As SqlCommand Dim setProperty As SettingsProperty Dim reader As SqlDataReader
Try cmd = New SqlCommand(strsql, conn)
With cmd .CommandType = Data.CommandType.Text .Parameters.AddWithValue("@M_NAME", CType(context("UserName"), String))
conn.Open()
reader = .ExecuteReader(Data.CommandBehavior.SingleRow)
End With If reader.HasRows Then reader.Read()
For Each setProperty In collection Dim setValue As New SettingsPropertyValue(setProperty) setValue.PropertyValue = reader(setProperty.Name) values.Add(setValue) Next End If
Return values Catch ex As Exception Throw ex Finally conn.Close() cmd.Dispose() End Try End Function |
Kent
"Wakey, wakey, hands off snakey!" |
|
|
|
Topic |
|
|
|