Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i have created 3 tier architcture program for login...user wil use username and password as parameters...here is my code for program


application tier:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Security.Principal
Imports System.Threading
Imports System.IO
Imports System.Text
Imports System.Collections.Generic
Imports bal.cbal
Namespace app
End Namespace
Public Class capp
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim verify As New bal.cbal
Dim dat As New bal.cbal
Dim use As String = UsernameTextBox.Text
Dim pas As String = PasswordTextBox.Text
verify(use, pas)
Me.Close()
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
Private Sub capp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'LoginDataSet.details' table. You can move, or remove it, as needed.
Me.DetailsTableAdapter.Fill(Me.LoginDataSet.details)
End Sub
End Class



business logic tier:


Imports System.Data
Imports System.Data.SqlClient
Imports System.Security.Principal
Imports System.Threading
Imports System.IO
Imports System.Text
Namespace cbal
Public Class bal
Dim check As New dal.cdal
Dim myDS As dal.cdal
Dim loginattempts As Integer
Public Function verify(ByVal use As String, ByVal pas As String) As String
If (use.Length > 10) Then
Throw New Exception("username must be atleast 10 characters")
ElseIf (pas.Length > 6) Then
Throw New Exception("password must be atleast 6 charcters long")
End If
loginattempts += 1
If loginattempts >= 3 Then
MsgBox("Too many failed login attempts", MsgBoxStyle.Exclamation)
Else
MsgBox("User Name not found. Please try again", MsgBoxStyle.Exclamation)
End If
Return myDS
End Function
End Class
End Namespace




data tier:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Security.Principal
Imports System.Threading
Imports System.IO
Namespace dal
Public Class cdal
Dim strConnect As String = "Data Source=pc325;Initial Catalog=pubs;Integrated Security=SSPI;"
Dim Con As SqlConnection = New SqlConnection(strConnect)
Dim login As Object
Dim mySDA As Object
Dim myDS As Object
Sub Main()
Try
Con.Open()
Console.WriteLine("Connection Opened")
Catch ex As SqlException
Console.WriteLine("Error: " & ex.ToString())
Finally
Con.Close()
Console.WriteLine("Connection Closed")
End Try
End Sub
Public Function check(ByVal use As String, ByVal pas As String)
If (use = use And pas = pas) Then
Console.WriteLine("login success")
Else
Console.WriteLine("Invalid name/password")
End If
Dim com As New SqlCommand("select * from details where use ='" & use & "'pas ='" & pas & "'", Con)
Dim SqlDataAdapter As New mySDA
Dim mySDA As New SqlDataAdapter(login)
Dim DataSet As New myDS
mySDA.Fill(myDS) 'cmdObj.Dispose()
Con.Close()
Return myDS
End Function
Private Sub SqlDataAdapter(ByVal p1 As Object)
Throw New NotImplementedException
End Sub
End Class
End Namespace
k..
the error s coming in application tier..
it s giving the error on line 19 tat Class 'WindowsApplication2.bal.cbal' cannot be indexed because it has no default property
Posted

1 solution

It's always Namspace.ClassName

You have written ClassName.Namspace i.e
VB
Imports bal.cbal
 
Share this answer
 
Comments
badri2020 30-Aug-10 5:22am    
hi,
in which line has the error occured..
i hav declared all things correctly
Ankur\m/ 30-Aug-10 5:43am    
In application tier, 8th line.
badri2020 30-Aug-10 6:11am    
after doing wat u hav told...still i cannot recover from the error..
Ankur\m/ 30-Aug-10 6:13am    
Did you correct this line also: "Dim verify As New bal.cbal"
badri2020 30-Aug-10 6:23am    
s..i hav corrected it also

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900