我如何使用Vb.net搜索我的记录 [英] How do i Search my record using Vb.net

查看:64
本文介绍了我如何使用Vb.net搜索我的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友!!



我有窗口表格带有'文本框'用于显示,'命令按钮'用于查找客户编号。



你能帮我解决一下如何在Vb.net中执行搜索命令吗?



我使用SQL Server 2008r2作为我的数据库。 ...我现在可以连接到我的数据库,并使用保存按钮插入我的一些记录。现在我想搜索一些记录,但我不知道该怎么做。你能给我一些示例代码或教程链接吗?如果你可以教我的话,对我来说将是一个很大的帮助...



谢谢:)

Hello Friends!!

I have window Form with 'text box' for display and 'command button' to find customer number.

Can you please help me how to perform search command in Vb.net?

Im using SQL Server 2008r2 as my Database.... i Can now Connect to my Database, and insert some of my records with 'SAVE' button. now i want to search some records but i dont know how to do that. can you please give me some sample codes or links to a tutorial? it would be a great help for me if you can teach me...

Thank you :)

推荐答案

你的问题在sql sintaxe中,因为你无法在where子句中比较那种方式。



尝试将你的代码更改为:



Your problem is within sql sintaxe as you can't compare that way at where clause.

try to change your code to this :

Private Sub Searchbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Searchbtn.Click
            Dim str as string = ""
            Str = "Select DesignID From Design_Parameters Where ParameterValue='" & Trim(txtname.text) & "'"
            ds = New DataSet()
            da = New SqlClient.SqlDataAdapter(Str, conn)
            da.fill(ds)
            If (ds.Tables(0).Rows.Count > 0) Then
                MessageBox("Record Found")
                'u can also fetch data from this dataset aslo
            Else
                MessageBox("No Record Found")
            End If
        End Sub


这篇关于我如何使用Vb.net搜索我的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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