How can i display data from Access database in a msgbox in vb.net windows form?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 19, 2012, 11:05 PM EDT
Try this...
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim ConnectionString As String = System.Configuration.ConfigurationSettings.AppSettings("dsn")
Dim con As OleDbConnection = New OleDbConnection(ConnectionString)
Dim com As OleDbCommand
Dim oledbda As OleDbDataAdapter
Dim ds As DataSet
Dim dt As DataTable
Dim str, sname As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
con.Open()
str = "select * from student"
com = New OleDbCommand(str, con)
Dim reader As OleDbDataReader = com.ExecuteReader
While reader.Read()
sname += reader(1) + vbCrLf
End While
MessageBox.Show(sname)
reader.Close()
con.Close()
End Sub
End Class
Thanks
If this post helps you mark it as answer