错误的语法附近& C# [英] error incorrect syntax near & c#

查看:60
本文介绍了错误的语法附近& C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

这是c#代码,在&附近给我错误的语法错误。

请给我任何帮助。





Hello,
this is c# code , give me error incorrect syntax near & .
any help please .


cmd.CommandText = "select username , password from passwords where username='"
                    + textBox1.Text + "' && password='" + textBox2.Text + "'";
                object obj = cmd.ExecuteScalar();

                if (obj == null) // No such username or password exist
                    label5.Text = "NotValid";
                else
                {
                    label5.Text = "Valid";
                }

推荐答案

您的问题是关于SQl查询您需要更改 AND 而不是&&





Your Question is about SQl Query you need to change AND instead of &&


cmd.CommandText = "select username , password from passwords where username='"
                    + textBox1.Text + "' and  password='" + textBox2.Text + "'";

这篇关于错误的语法附近& C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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