![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| hi guys, once again i'm stuck ![]() I did try for a while on my own, i know it's sad ![]() anywho moving on, as the name suggests I want to create a function to return a users name based on their user ID. here's the page where i tried to write the function: Code: Imports Microsoft.VisualBasic
Imports System
Imports System.ComponentModel
Imports Keith.ProjectManager.BO
Namespace Keith.ProjectManager.Bll
Public Class Common
Public Shared Sub CheckLogIn()
If Len(HttpContext.Current.Session("UserName")) < 1 Or HttpContext.Current.Session("UserName") = "Guest" Then
HttpContext.Current.Session("UserName") = ""
HttpContext.Current.Session("UserID") = ""
HttpContext.Current.Response.Redirect("default.aspx")
Dim LogOutMsg As String
LogOutMsg = "Your session has expired"
End If
End Sub
Public Shared Function GetUSerName(ByVal uID As Integer) As String
Dim UserList As New UserList
UserList = UserManager.GetItem(uID)
Dim myUser As New Users
Return myUser.Name
End Function
End Class
End Namespace
Code: <DataObjectMethod(DataObjectMethodType.Select, False)> _
Public Shared Function GetItem(ByVal id As Integer) As Users
Return UserDB.GetItem(id)
End Function
Code: Public Shared Function GetItem(ByVal id As Integer) As Users
Dim myUser As Users = Nothing
' Using
Dim myConnection As MySqlConnection = New MySqlConnection(myConfig.myConnection)
Try
Dim myCommand = New MySqlCommand(QueryUserDB.Item(id), myConnection)
myConnection.Open()
'Using
Dim myReader As MySqlDataReader = myCommand.ExecuteReader
Try
If myReader.Read Then
myUser = FillDataRecord(myReader)
End If
myReader.Close()
Finally
CType(myReader, IDisposable).Dispose()
End Try
myConnection.Close()
Finally
CType(myConnection, IDisposable).Dispose()
End Try
Return myUser
End Function
Private Shared Function FillDataRecord(ByVal myDataRecord As IDataRecord) As Users
Dim myUser As Users = New Users
myUser.Idkey = myDataRecord.GetInt32(myDataRecord.GetOrdinal("idkey"))
myUser.Name = myDataRecord.GetDateTime(myDataRecord.GetOrdinal("name"))
myUser.Email = myDataRecord.GetString(myDataRecord.GetOrdinal("email"))
myUser.Password = myDataRecord.GetString(myDataRecord.GetOrdinal("psswrd"))
Return myUser
End Function
Code: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30311: Value of type 'Keith.ProjectManager.BO.Users' cannot be converted to 'Keith.ProjectManager.BO.UserList'. Source Error: Line 20: Public Shared Function GetUSerName(ByVal uID As Integer) As String Line 21: Dim UserList As New UserList Line 22: UserList = UserManager.GetItem(uID) Line 23: Line 24: Dim myUser As New Users Source File: C:\Inetpub\wwwroot\keithdesign\App_Code\global\BLL\Common.vb Line: 22 |
| Sponsored Links |
|
#2
| ||||
| ||||
| fixed that error ![]() Code: Public Shared Function GetUSerName(ByVal uID As Integer) As String
Dim Users As New Users
Users = UserManager.GetItem(uID)
Dim myUser As New Users
Return myUser.Name
End Function
|
|
#3
| ||||
| ||||
| UserList = UserManager.GetItem(uID) UserManager.GetItem returns a Users Object not a List. Are you trying to get a list of User Names or an individual one? |
|
#4
| ||||
| ||||
| I realised that look above |
|
#5
| ||||
| ||||
| Quote:
Why not just have Return Users.Name? And then, why is this not just in your page code? If you wanted to use it a lot, just create the instance in your Master Page .master Code: Public User As Users = UserManager.GetItem(uID) Code: label1.text = Master.User.Name |
|
#6
| ||||
| ||||
| no your not missing anything, I most likely am ![]() I just did it that way as that's how I am used to doing things? ![]() so in my masterpage.master.vb i just add: Code: Public User As Users = UserManager.GetItem(uID) Shem |
|
#7
| ||||
| ||||
| I went by your example that you did for me when we populated Projects? |
|
#9
| ||||
| ||||
| also how will I use it in my Repeater, as i need to convert diff userID's on same page? |
|
#10
| ||||
| ||||
| Quote:
Code:
Public Shared Function GetUSerName(ByVal uID As Integer) As String
Dim UserList As New UserList
UserList = UserManager.GetItem(uID)
Dim myUser As New Users
Return myUser.Name
End Function
|
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| export to excel function prompt help | Rebelle | JavaScript Programming | 2 | April 14th, 2008 10:40 AM |
| Concatenation of Column Data function | AOG123 | Microsoft Access | 0 | March 25th, 2008 06:53 AM |
| [ASP.Net/General] VB.Net/C# BBCode Function | jmurrayhead | Code Samples | 0 | March 20th, 2008 09:44 AM |
| [SQL] Concatenation of Column data function.... | Lauramc | Code Samples | 0 | March 17th, 2008 12:32 PM |