2014-02-28 88 views
0

我试图在我的Ms Access数据库中获取特定值。 示例。 这是我的数据库中的表..如何在使用VB.net的MS Access中获取特定值

我有3列,即姓名,年龄和电话号码。 这里是值..

行1 = [姓名=约翰,年龄= 13,电话号码= 456)]。

第2行= [姓名=标记,年龄= 11,电话号码= 123)]。

行3 = [名称=马爷,年龄= 15,电话NUM = 789)]

然后实例我只想跟马克的时代,这是11 或约翰的电话号码,这是456 ..和 使用文本框显示它。 所有我想要的是让特定的值,我不关心其他值..

以及即时通讯使用Visual Studio 2012和MS Access 2010 ..

我的继承人代码.. 进出口新约VB.net,以便我不熟悉这些代码。^ _^

con =新的OleDbConnection(“Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\ Users \ Vincelouie \ Desktop \ FBES INFO SYSTEM \ Database1.accdb“) con.Open()

Dim selectString As String = "SELECT Age FROM Table1" 
    ' this line passes in the SQL statement and the OleDbConnection object. 
    Dim cmd As OleDbCommand = New OleDbCommand(selectString, con) 

    'Send the CommandText to the connection, and then build an OleDbDataReader. 

    Dim reader As OleDbDataReader = cmd.ExecuteReader() 

    reader.Read() 
    StudentTextBox.Text = reader.GetValue(0).ToString() 


    'Close the reader and the related connection. 
    reader.Close() 
    con.Close() 

谢谢.. 所有帮助都非常感谢..

回答

相关问题