Hello,
i have an access database (wwtbamDB.mdb) with Question1to5table, the table have the ID,Questions,Ans1,Ans2,Ans3,Ans4 column.
i want to display the content on the appropriate button on a windows form in vb.net.
Thanks for you help.
Code:
Public Class Form1 : Inherits System.Windows.Forms.Form Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
End Class
'to open and retrieve
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_Data Source=C:\Users\Timosoft\Documents\wwtbamDB.mdb;")
'provider to be used when working with access database
cn.Open()
cmd = New OleDbCommand("select * from Question1to5table", cn)
dr = cmd.ExecuteReader
While dr.Read()
Main1.QuestnBTN1.Text = dr(Questions)
Main1.Answerbtn1.Text = dr(Answer1)
Main1.Answerbtn2.Text = dr(Answer2)
Main1.Answerbtn3.Text = dr(Answer3)
Main1.Answerbtn1.Text = dr(Answer4)
' loading data into TextBoxes by column index
End While
Catch
End Try