如何为登录表单执行代码 [英] How to do code behind for login form

查看:85
本文介绍了如何为登录表单执行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.







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

推荐答案

您好



您提到的错误是SQL Server异常。您是需要检查两件事来解决这个问题

1)检查你要连接的数据库中是否存在dbo.CLM_User表。

2)检查它是否属于dboschema。你可以右键单击表并检查表的模式,或者它将是表名的前缀的一部分,如schema.table_name



如果这样可以解决错误,请告诉我。



谢谢

Ashish
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


然后我想你可能连接到错误的数据库。可以。检查你的连接字符串。也尝试在运行时看到连接对象值。它可能会告诉你要连接的数据库。
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.


你能给出确切的错误信息,它是hapeening因为在您的代码中分配了一些incompatibltype。变量的数据类型与指定的值不匹配。
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.


这篇关于如何为登录表单执行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆