2014-02-28 87 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() 

謝謝.. 所有幫助都非常感謝..

回答

相關問題