Click here to Skip to main content
16,019,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm trying to make a simple login form with asp.net and db2 database ..

but when i try to run it , in " Using db2Conn As New DB2Connection(Sconn.Stringkoneksi) " there is a error message " Invalid argument " ... why "Stringkoneksi" not read the connection string from sconn class ??

btw , i made the connection string in web.config ..

sorry if my english bad , thanks for the help ... i appreciate that

VB
 Partial Class H_login
    Inherits System.Web.UI.Page

    Public Class Sconn
        Public Shared Function Stringkoneksi() As String
            Return ConfigurationManager.ConnectionStrings("LoginSystem").ConnectionString
        End Function

    End Class

    Protected Sub cmdlogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdlogin.Click


        Using db2Conn As New DB2Connection(Sconn.Stringkoneksi)
            db2Conn.Open()

            Dim strQuery As String = "SELECT * FROM dblogin WHERE USERID ='" & Me.tbUserName.Text & "' and PASS = '" & Me.tbPassword.Text & "';"
            Dim db2Cmd As New DB2Command(strQuery, db2Conn)
            Dim db2Rdr As DB2DataReader = db2Cmd.ExecuteReader()
            Dim strusername As String
            Dim strpassword As String

            strusername = ""
            strpassword = ""
            While db2Rdr.Read()
                strusername = db2Rdr.GetString(0)
                strpassword = db2Rdr.GetString(5)
            End While

            If strusername = "" Then
                Me.label1.Text = "UserName tidak ada!"
            Else
                If strpassword <> Me.tbPassword.Text Then
                    Me.label1.Text = "Password anda salah!"
                Else
                    Me.label1.Text = "Login sukses!"
                End If
            End If

            db2Conn.Close()
        End Using

    End Sub

End Class 
Posted
Comments
Sinisa Hajnal 16-Sep-14 2:30am    
Did you check the value of Stringkoneksi? XML config is case sensitive, maybe you have loginSystem or some other mistype and you get nothing from config?

Also, check that you have all the information needed:
Server=myAddress:myPortNumber;Database=myDataBase;UID=myUsername;PWD=myPassword;

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