登录表单问题 [英] Problem with login form

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

问题描述

我用wpf和entityframework写了一个登录表单,但编码有问题。发生以下错误





变量 登录 定义行以下错误。



我尝试过:



I wrote a login form with wpf and entityframework but I have a problem coding. The following error is taken


The variable login definition line takes the following error.

What I have tried:

private void btnVoroud_Click(object sender, RoutedEventArgs e)
        {
            IDMS_dbEntities db = new IDMS_dbEntities();
            var login = db.tblUsers.Single();
            if (txtKarbari.Text == login.UserName && txtPassword.Password.ToString() == login.Password)
            {
                this.Hide();
                WinRemainder win = new WinRemainder();
                win.ShowDialog();
            }
            else
            {
                lblMessage.Visibility = Visibility.Visible;
                lblMessage.Content = "نام کاربری یا رمز عبور اشتباه می باشد";
                txtKarbari.Text = "";
                txtPassword.Password = "";
                mohlat--;
                if (mohlat == 0)
                {
                    lblMessage.Content = "تعداد دفعات ورود رمز تمام شد";
                    mohlat = 4;
                    btnVoroud.IsEnabled = false;

                }
            }
	}











异常抛出:EntityFramework.SqlServer.dll中的'System.Data.Entity.Core.EntityCommandCompilationException'



附加信息:准备命令定义时发生错误。详见内部异常。





tblUser:






Exception thrown: 'System.Data.Entity.Core.EntityCommandCompilationException' in EntityFramework.SqlServer.dll

Additional information: An error occurred while preparing the command definition. See the inner exception for details.


tblUser:

CREATE TABLE [dbo].[tblUser] (
    [Id]       INT           IDENTITY (1, 1) NOT NULL,
    [Name]     NVARCHAR (50) NULL,
    [Family]   NVARCHAR (50) NULL,
    [UserName] NVARCHAR (50) NOT NULL,
    [Password] NVARCHAR (50) NULL,
    CONSTRAINT [PK_tblUser] PRIMARY KEY CLUSTERED ([UserName] ASC)
);







我希望你理解我的问题的意思,因为我不再懂英语了




I hope you understand the meaning of my question because I do not know English anymore

推荐答案

查看您的错误消息:

Look at your error message:
Exception thrown: 'System.Data.Entity.Core.EntityCommandCompilationException' in EntityFramework.SqlServer.dll

Additional information: An error occurred while preparing the command definition. See the inner exception for details.

因此,请使用调试器,并查看InnerException:它将包含希望可以帮助您的详细信息。

So use the debugger, and look at the InnerException: it will contain details which hopefully should help you.


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

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