如何使用VB 2008从数据表获取值到文本框 [英] how to get value from data table to a textbox using VB 2008

查看:95
本文介绍了如何使用VB 2008从数据表获取值到文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI all



我正在编程,我有一个数据库访问列ID,Nps,Npp



我需要做的是。如果我输入Npp列上列出的数字,我需要得到Nps上的数字。



如果不是NPP,我能够进行此操作输入身份证号码。例如,NPP列上的数字就像这样8N5DHAFA1010 ++ - 1Y 100



使用id来获取Nps值的代码是下一个



Me.DecoderBindingSource.Filter =id ='& Me.TextBox4.Text& '



TextBox2.Text = NpsTextBox.Text





内容来自评论 - Maciej Los



我有Visual Studio 2008和即时通讯使用VB



好​​的这是我有的代码,但是在这个数据库中,我有3列代码,我们创建示例:第1列ID,第2列条形码,第3列CodS
第1列中的
是来自访问的通常ID

在第2列中我们创建了一个代码,用于识别和对象622022

在第3列我们有识别对象L6 CM602-2 T2 Z2R

所以,如果我扫描文本框1上的条形码,它将带我在文本框2上识别,并且工作正常。



现在我想对供应商零件编号8N5DHAFA1010 ++ - 1Y 100做同样的事情,并带来部件编号XXXXX-XXXXX

但它确实如此不工作,似乎只与数字而不是所有人物一起工作,我真的很喜欢st,我对这一切都很陌生。希望我自己解释一下。



祝你好运

HI all

Im noob to programing and i have a database in access with columns ID, Nps, Npp

what i need to do is. if i type a number listed on Npp column, i need to get as result the number on Nps.

i'm able to to this operation if instead of NPP i type the Id number. and as example the number on the NPP column are like this 8N5DHAFA1010++-1Y 100

the code that works using the id to to get the Nps value is the next

Me.DecoderBindingSource.Filter = "id = ' " & Me.TextBox4.Text & "'"

TextBox2.Text = NpsTextBox.Text


The content comes from comment - Maciej Los

I have Visual studio 2008 and im using VB

Ok this is the code i have that is working, but on this database i have 3 columns a code that we create example: Column 1 ID, Column 2 Barcode, Column 3 CodS
in column 1 is the usual id from access
in column 2 we create a code that will identify and object " 622022 "
in column 3 we have the identification of the object " L6 CM602-2 T2 Z2R "
so if i scan the barcode on textbox 1 it will bring me on textbox 2 the Identification, and its working OK.

Now i want to do the same with a vendor part number " 8N5DHAFA1010++-1Y 100 " and bring the propetary part number "XXXXX-XXXXX"
but it does not work, it seems that only work with number and not all characters, im really lost, and im new to all this. hope that i explain myself.

Best regards

Public Class Form1

    Private Sub DecoderBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DecoderBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.DecoderBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.ControldeMatDataSet)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'ControldeMatDataSet.Decoder' table. You can move, or remove it, as needed.
        Me.DecoderTableAdapter.Fill(Me.ControldeMatDataSet.Decoder)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.DecoderBindingSource.Filter = "Barcode = ' " & Me.TextBox1.Text & "'"
        TextBox2.Text = CodSTextBox.Text
    End Sub
End Class





[/ EDIT]



[/EDIT]

推荐答案

尝试用这个替换过滤器行:



Try to replace the filter line with this one:

Me.DecoderBindingSource.Filter = "Barcode LIKE '*" & Me.TextBox1.Text & "*'"





请参阅此处如何使用过滤器:



http://msdn.microsoft.com/fr-fr/library/system.data.datacolumn.expression%28v=vs.110%29 .aspx [ ^ ]


这篇关于如何使用VB 2008从数据表获取值到文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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