Results 1 to 7 of 7

Thread: [RESOLVED] Selecting field from database and showing it on a button (MS Access)

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    108

    [RESOLVED] Selecting field from database and showing it on a button (MS Access)

    I got table1 with the columns ID, Name and IP. Can I fetch a name from the database (depending on ID) and show it as the text on a button when the form loads?

    Something like

    VB Code:
    1. Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source= " & System.AppDomain.CurrentDomain.BaseDirectory & "\db1.mdb"
    2.         Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
    3.  
    4.         Dim queryString As String = "SELECT Name FROM table WHERE ID = '2'"
    5.         Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
    6.         dbCommand.CommandText = queryString
    7.         dbCommand.Connection = dbConnection
    8.  
    9.         Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
    10.         dataAdapter.SelectCommand = dbCommand
    11.         Dim dataSet As System.Data.DataSet = New System.Data.DataSet
    12.         buttonConf1.Text = dataSet.ToString

    which sets the text on the button to System.Data.DataSet...

    so how should it all actually look like?

    if the code is completely wrong could you tell me how it should be please
    Last edited by Darkstorm; Jan 14th, 2006 at 03:22 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width