我们如何将文本框值与vb.net中的数据库值进行比较 [英] how we compare textbox value with database value in vb.net

查看:202
本文介绍了我们如何将文本框值与vb.net中的数据库值进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时制作电子纸系统

如何在登录按钮上将文本框字段与SQL数据库值进行比较?

解决方案

如何在登录按钮上将文本框字段与SQL数据库值进行比较?

步骤:

1.在登录按钮上按,提高点击事件。在此单击处理程序中写下您的比较代码。

2.现在,使用ADO.NET连接到数据库。形成一个查询,用于比较DB中的值

3.运行查询并返回结果

4.根据返回的结果采取措施。



很少有人会提供帮助:

MSDN:使用ADO.NET访问数据 [ ^ ]

为初学者使用ADO.NET [ ^ ]

使用C#读取,插入,更新和删除简单的ADO.NET数据库。 [ ^ ]


 con.con_open()

Dim cmdlogin As SqlCommand(( SELECT * FROM users WHERE user_name ='& _
txtuname.Text& 'and password ='& _
txtpassword.Text& '),con.con)
Dim dalogin As SqlDataAdapter
Dim dslogin As Data.DataSet
dalogin.SelectCommand = cmdlogin
cmdlogin.ExecuteNonQuery()
dslogin.Clear()
dalogin.Fill(dslogin, users


如果 dslogin.Tables( 0 )。Rows.Count> 0 然后

其他

结束 如果

< span class =code-comment>' --------------------或

如果 txtusername.text = dslogin.Tables( 0 )。行(< span class =code-digit> 0 )。Item( 0 )。ToString 然后

else

end 如果

' ----- ---------------

con.con_close(


登录按钮上的SQL数据库值

请不要这样做是你自己,使用 ASP.NET身份验证 [ ^ ]。



安全是一个棘手的问题,需要深入了解各种技术。 ASP.Net提供开箱即用的身份验证和授权,因此无需自行实现。



祝你好运

Espen Harlinn

i m making electronic paper system
how can i compare textbox fields with SQL database values on my login button?

解决方案

How can i compare textbox fields with SQL database values on my login button?
Steps:
1. On login button press, raise the click event. Write your comparison code here in this click handler.
2. Now, using ADO.NET, connect to database. Form a query for comparison of the value in DB
3. Run the query and get back the result
4. Take action based on the result returned.

Few references that would help:
MSDN: Accessing Data with ADO.NET[^]
Using ADO.NET for beginners[^]
Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^]


con.con_open()

        Dim cmdlogin As New SqlCommand(("SELECT * FROM users WHERE user_name='" & _
                                            txtuname.Text & "' and password='" & _
                                            txtpassword.Text & "'"), con.con)
        Dim dalogin As New SqlDataAdapter
        Dim dslogin As New Data.DataSet
        dalogin.SelectCommand = cmdlogin
        cmdlogin.ExecuteNonQuery()
        dslogin.Clear()
        dalogin.Fill(dslogin, "users")


        If dslogin.Tables(0).Rows.Count > 0 Then

        Else
            
        End If

'--------------------or

        if txtusername.text=dslogin.Tables(0).Rows(0).Item(0).ToString then

        else

        end if

'--------------------

        con.con_close(


SQL database values on my login button
Please don''t do this yourself, use ASP.NET Authentication[^].

Security is a thorny issue which requires an in depth understanding of a wide range of technologies. ASP.Net provides authentication and authorization out of the box, so there is no need to implement this yourself.

Best regards
Espen Harlinn


这篇关于我们如何将文本框值与vb.net中的数据库值进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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