Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I've use this code for login form, but it display error 'Invalid object name 'dbo.CLM_User' at line 14. Please check for me because I'm new in ASP.Net,thank you.


VB
Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click

        sql = "SELECT * FROM dbo.CLM_User WHERE CLM_loginID = '" & Me.txtUserId.Text & "' AND CLM_loginPWD = '" & Me.txtPassword.Text & "'"
        Dim result As Integer = 0

        dbconn = New OleDb.OleDbConnection(strCon)
        dbcomm = New OleDbCommand(sql, dbconn)
        dbcomm.Parameters.AddWithValue("", Me.txtUserId.Text)
        dbcomm.Parameters.AddWithValue("", Me.txtPassword.Text)
        dbconn.Open()

        Session("User") = Me.txtUserId.Text
        result = DirectCast(dbcomm.ExecuteScalar(), Integer)

        If fnExec(sql, tEdit) = 1 Then
            setMsg(Me, msgBoxSaved, "strKey1")
        Else
            setMsg(Me, msgBoxSaveFailed, "strKey1")
        End If

        If result > 0 Then
            Response.Redirect("frmWebForm2.aspx")
        Else
            setMsg(Me, "Wrong Id or Password", "strkey1")
        End If
    End Sub
Posted

Hi

The error you have mentioned is SQL Server exception.You need to check two things to resolve this
1) Check if the dbo.CLM_User table exists in the database you are connecting to.
2) Check if it belongs to the "dbo" schema.You can right click the table and check the schema for the table or it will be part of prefix for the table name like schema.table_name

Please let me know if this resolves the error.

Thanks
Ashish
 
Share this answer
 
Comments
U_Hanisa 1-Oct-14 0:17am    
Yes,the table is exists in database and it belongs to dbo.
Then I think you might be connecting to the wrong database .Can you check your connection string.Also try to see the connection object value at run time.It may tell you the database you are connecting to.
 
Share this answer
 
Comments
U_Hanisa 1-Oct-14 0:52am    
Yea,you're right. But when I debug, the new error popup 'Specified cast is not valid'. Sorry, because I don't know how to fix the error.
Can you give the exact error message,it is hapeening because some incompatibltype is being assigned in your code.The data type of the variable is not matching with the assigned value.
 
Share this answer
 

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