.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> ADO.NET >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Retrieve the date from table into labels.

Posted By:laptop charles       Posted Date: June 27, 2010    Points: 10    Category: ADO.NET    URL: http://www.dotnetspark.com  

I used three label and get the data from table.

Imports System.Data.OleDb
Public Class Form2
    Inherits System.Windows.Forms.Form
    Dim cn As OleDbConnection
    Dim cmd As OleDbCommand
    Dim dr As OleDbDataReader
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As  _
    System.EventArgs) Handles MyBase.Load
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_Data Source=D:\library.mdb;")
            'provider to be used when working with access database
            cmd = New OleDbCommand("select * from sal", cn)
            dr = cmd.ExecuteReader
            While dr.Read()
                TextBox1.Text = dr(0)
                TextBox2.Text = dr(1)
                TextBox3.Text = dr(2)
                ' loading data into TextBoxes by column index
            End While
        End Try
    End Sub
End Class


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend