Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo,

folgendes Problem: Ich bin gerade dabei für meinen Ausbildungsbetrieb eine ASP.Net Anwendung zu erstellen. Für diese Anwendung soll auch ein Login stattfinden. Beim Ausführen erscheint allerdings der Fehler das kein Objektverweis auf eine Objektinstanz festgelegt wurde. Der Code sieht folgender Maßen aus:



Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate


        'Instanzen der Klassen Funktionen und Datenbank

        Dim funk As New Funktionen

        Dim Daten As New Datenbank


        Dim Benutzername As String

        Benutzername = Login1.UserName


        Dim Passwort As String

        Passwort = funk.MD5StringHash(Login1.Password)


        If Daten.Login(Passwort, Benutzername) = True Then




        End If


    End Sub



Und die dazugehörigen Klassen mit den Methoden zur Verschlüsselung des Passworts und der Überprüfung ob das Passwort stimmt.


Public Function Login(ByVal Passwort As String, ByVal Benutzername As String) As Boolean


        con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Martin\Documents\Visual Studio 2010\Projects\Taschenrechner\Taschenrechner\App_Data\Taschenrecher_DB.accdb"


        cmd.Connection = con


        cmd.CommandText = "select * from Login"




        Try

            con.Open()


            cmd.ExecuteReader()


            Do While reader.Read

                If reader("Benutzername") = Benutzername And reader("Passwort") = Passwort Then

                    con.Close()

                    Return True

                Else

                    con.Close()

                    Return False

                End If


            Loop



        Catch ex As Exception

            MsgBox(ex.Message)


        End Try


        Return False


    End Function




Public Function MD5StringHash(ByVal strString As String) As String

        Dim MD5 As New MD5CryptoServiceProvider

        Dim Data As Byte()

        Dim Result As Byte()

        Dim Res As String = ""

        Dim Tmp As String = ""


        Data = Encoding.ASCII.GetBytes(strString)

        Result = MD5.ComputeHash(Data)


        For i As Integer = 0 To Result.Length - 1

            Tmp = Hex(Result(i))


            If Len(Tmp) = 1 Then

                Tmp = "0" & Tmp


            End If


            Res += Tmp


        Next


        Return Res


    End Function


Schonmal vielen Dank für eure Hilfe.

Also irgendwie steh ich auf dem Schlauch, mit welchem Wert initialisiere ich den Typ?

Wieso funktioniert dann aber das?


Dim Daten As New Datenbank


If Daten.Benutzer_Neu(txtVorname.Text, txtName.Text, txtBenutzer.Text, txtPasswort.Text) = True Then


                lblEintr.ForeColor = Drawing.Color.Green

                lblEintr.Text = "Die Dateneintragung war erfolgreich!"


End If



Hallo

wäre prinzipiell nicht schlecht uns zu schreiben WO der Fehler auftritt (welche Klasse). Ich gehe davon aus, dass es in der Klasse ist in der du die Funktion Login hast.

Dort schreibst du

con.ConnectionString

Tipp:

Hast du con vorher inintialisiert ?

Gruß Hans-Jörg

Danke für eure Hilfe. Jetzt hab ich es gesehen, ich habe den Reader nicht initialisiert, so kann es natürlich nicht funktionieren :-D

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.