kalpesh says:
If your dt count not equal to zero means your user is successfully login.
Yes, this is understood and implemented correctly .
kalpesh says:
In same dt you already have record details for the user you need from table member.
This is how I do it ? Do I need this function?
Dim s As String = "primaryKeyValue"
Dim foundRow As DataRow = DataSet1.Tables("AnyTable").Rows.Find(s)
If foundRow IsNot Nothing Then
MsgBox(foundRow(1).ToString())
Else
MsgBox("A row with the primary key of " & s & " could not be found")
End If
Or is this function sufficient to perform the required?
If reader.HasRows Then
reader.Read()
Email = reader.Item("Email").ToString()
Password = reader.Item("password").ToString()
End If
reader.Close()
conn.Close()
Return reader
When I apply the code as follows all members appear to me ..
Vb Page :
Protected Sub LinkButtonLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButtonLogin.Click
Dim objM As New DB_Member
objM.ProEmail = txtid.Text
objM.ProPassword = txtpassword.Text
Dim dt As DataTable = objM.FindPass()
If dt.Rows.Count <> 0 Then
LinkButtonLogin.Visible = False
LinkButtonLogout.Visible = True
LinkButtonRegister.Visible = False
Dim objM3 As New DB_Member
objM.ProEmail = txtid.Text
objM.ProPassword = txtpassword.Text
Dim reader As SqlDataReader = objM3.FindMember()
Dim objC As New DB_Member
Dim dt2 As DataTable = objC.FindMebPage()
RepeaterMember.DataSource = dt2
RepeaterMember.DataBind()
LabelNameMember.Visible = True
LabelNameMember.Text = "Welcome Mr/Ms." + objM.ProEnglishName
txtid.Visible = False
txtpassword.Visible = False
Else
lblMsg.Text = "Plz Check U Email and Password"
End If
End Sub
App Code :
Public Function FindMebPage() As DataTable
Getconnection()
Dim sql As String = "SELECT Member.MemberID,Member.EnglishName,Member.ArabicName,Member.MemberImage,Member.DateOfMembership,Member.Email,Member.Phone,Member.CityID,Member.PCTLEVELID,MEmber.ISIDLEVELID,Member.SBLEVELID,Member.CategoryID,Member.PCTID,Member.ISIDID,Member.SBSID,Member.CountryID,Country.CountryName,City.CityName,Category.CateName,PCTLEVEL.PCTName,PCTLEVEL.PCTNote,ISIDLEVEL.ISIDNote,SBLEVEL.SBSNote,ISIDLEVEL.ISIDName,SBLEVEL.SBName FROM Member,City,Category,Country,PCTLEVEL,ISIDLEVEL,SBLEVEL Where City.CityID=Member.CityID AND Member.CountryID = Country.CountryID AND Category.CategoryID = Member.CategoryID AND PCTLEVEL.PCTLEVELID =Member.PCTLEVELID AND ISIDLEVEL.ISIDLEVELID =Member.ISIDLEVELID AND SBLEVEL.SBLEVELID =Member.SBLEVELID "
Dim dt2 As New DataTable
Dim da As New SqlDataAdapter(sql, Me.conn)
If CountryID <> 0 Then
da.SelectCommand.CommandText &= "AND City.CountryID = @CountryID"
da.SelectCommand.Parameters.Add("@CountryID", SqlDbType.Int).Value = CountryID
End If
.
.
.
Try
Getconnection()
da.Fill(dt2)
Catch ex As SqlException
Me.Msg = "Error Message"
Finally
Try
Me.conn.Close()
Catch
End Try
End Try
Return dt2
End Function
Public Function FindPass() As DataTable
Getconnection()
Dim SQL As String = "SELECT * from Member where Email=@Email and Password=@Password "
Dim dt As New DataTable
Dim da As New SqlDataAdapter(SQL, conn)
da.SelectCommand.Parameters.Add("@Email", SqlDbType.NVarChar).Value = Email
da.SelectCommand.Parameters.Add("@Password", SqlDbType.NVarChar).Value = Password
Try
da.Fill(dt)
Catch ex As Exception
'Error
Finally
conn.Close()
End Try
Return dt
End Function
Public Function FindMember() As SqlDataReader
Getconnection()
Dim comm As SqlCommand
comm = New SqlCommand("select * from Member where Email=@Email and Password=@Password ", conn)
Dim reader As SqlDataReader
comm.Parameters.Add("@Email", SqlDbType.NVarChar).Value = Email
comm.Parameters.Add("@Password", SqlDbType.NVarChar).Value = Password
reader = comm.ExecuteReader()
'reader = comm.ExecuteReader(CommandBehavior.CloseConnection)
If reader.HasRows Then
reader.Read()
Email = reader.Item("Email").ToString()
Password = reader.Item("password").ToString()
End If
reader.Close()
conn.Close()
Return reader
End Function
I understood what you said in the past .. But all I want is the right way from my code ..
Thank you for your patience and slow understanding :(