使用passwordbox内容验证SQL数据库数据| WPF | C#|产品密钥 [英] Verifying SQL database data with passwordbox content | WPF | C# | product key
问题描述
大家好,如果用户输入正确的产品密钥,我试图让我的登录窗口只继续输入一串代码。
输入正确的产品密钥时需要执行的代码:
Hi all, I'm trying to get my login window to only continue a string of code if the user enters 1 of the correct product keys.
The code that I need to execute when 1 of the correct product keys are entered:
MainWindow win2 = new MainWindow();
win2.Show();
this.Close();
如果有办法向我展示如何在我的服务器上设置我的数据表,那就太棒了。
----------------------------------
这是当ANYTHING在密码框中时当前激活的代码:
If there's a way of showing me how I should set out my data table on my server as well, that would be great.
----------------------------------
Here's the code that currently activates when ANYTHING is in the password box:
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
MainWindow win2 = new MainWindow();
win2.Show();
this.Close();
}
------------------------------ ----
我的尝试:
我'看着谷歌,但我似乎无法找到适用于密码箱的东西。 (我是WPF的新手#)
----------------------------------
What I have tried:
I've looked all over Google, but I can't seem to find something that works with password boxes. (I'm quite new to WPF c#)
推荐答案
在这里试试:密码存储:如何做到这一点。 [ ^ ]
在不知道SQL Server表的情况下,SQL问题很难帮到你结构,显然。包括具体细节。
PasswordBox类型控件支持属性密码服务器端,但出于安全原因不能绑定它。详情请见: [ ^ ]
哪个我想知道你为什么要对文本框的文本更改事件采取行动?
显然你不想对每一个改变采取行动,但是直到按下一些按钮才会动作。
You SQL question is hard to help you with without knowing your SQL server table structure, obviously. Do include for specifics.
A PasswordBox type control supports a property Password server side, however it cannot be bound to for security reasons. See details: [^]
Which me wonder why you're acting on the text changed event of a textbox?
Clearly you don't want to act on every change but not until for instance some button is pressed.
<StackPanel Margin="10">
<Label>Text:</Label>
<TextBox />
<Label>Password:</Label>
<PasswordBox id="MyPasswordBox" />
</StackPanel>
然后在代码隐藏中你可以简单地访问它
and then on the codebehind you can simply access it with
string password = MyPasswordBox.Password;
其中包含在像对象这样的事件中,请记得首先将其拆箱。
Of it is boxed in an event like object, remember to unbox it first.
var pwBox = (PasswordBox)sender;
但如果发件人不要试试是你的按钮事件;)
But don't try it if you sender is on your button event ;)
这篇关于使用passwordbox内容验证SQL数据库数据| WPF | C#|产品密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!