Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
i hav created a program to login user using his username and password...but the program gives the error "class(classname) cannot be indexed because it has b=no default property"...how to overcome this error...plz guide me
regards
badri
Posted

Well, your first step is to show us your code so we can understand what's going on. Either that or learn to use google[^]
 
Share this answer
 
Comments
badri2020 30-Aug-10 7:48am    
Reason for my vote of 3
ghgh
You forgot to instantiate your class using New keyword.

If your class is clsMain then instantiate it as

clsMain obj =new clsMain();

Hope this may help u.. :)
 
Share this answer
 
Comments
badri2020 30-Aug-10 7:47am    
i hav instantiated all classes with the new keyword...plz tell me on which line i ve to instantiate the class..i can't find wat u r telling
Sandesh M Patil 30-Aug-10 7:49am    
Please provide the code after analysing it, i will tell u.
badri2020 30-Aug-10 7:57am    
i>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
Sandesh M Patil 30-Aug-10 8:04am    
Dim DataSet As New myDS

what is this? you have to declare it as

Dim myDS As New DataSet

And also Dim SqlDataAdapter As New mySDA this one

you didnt get errors on this lines?

Please visit http://www.codeproject.com/Forums/1580229/Hindi.aspx
General India Topics section of Code Project and ask your questions there.
Ankur\m/ 30-Aug-10 8:08am    
There are so many error in this code. I already told him in another thread. It's a Re-post.

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