SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Downloaden Sie, um offline zu lesen
Database Connectivity with Data Reader




                                               Figure 17.5

Step 1.Create a database Employee in Ms Access 2003/2007/2010/2013 and then create a table Emp. Field
of EMP table is: Ecode, Ename, Eage, Edesig, and Esalary. Now adding the data into the table.
Step 2. Open Visual Studio .Net 2008/2010/2012.
Step 3. Click on view menu and open server explorer.
Step 4. Right click on data connections then select add connection. Now select data source Microsoft
Access Database file and then select the database file name. Where the database is stored and then click
ok button.
Step 5. When the connection is created then copy the path of file in properties window.
Path is this:

"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:UsersTiwariDesktopEmployee.mdb")

Then design a form, coding in a form and then run it.

Example 15.2

Imports System.Data.OleDb
Public Class Form2
    Dim con As OleDbConnection
    Dim cmd As OleDbCommand
    Dim dr As OleDbDataReader
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
        'Save Record
        Try
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:UsersTiwariDesktopEmployee.mdb")
            con.Open()
            cmd = New OleDbCommand("insert into Emp values('" & TextBox1.Text
& "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text &
"','" & TextBox5.Text & "') ", con)
            cmd.ExecuteNonQuery()
            MessageBox.Show("Record Inserted", "Updated",
MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
        'Update Record
        Try
            con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:UsersTiwariDesktopEmployee.mdb")
            con.Open()
            cmd = New OleDbCommand("Update Emp set Ecode='" & TextBox1.Text &
"',Ename='" & TextBox2.Text & "',Eage='" & TextBox3.Text & "',Edesig='" &
TextBox4.Text & "', Esalary= '" & TextBox5.Text & "' where Ecode='" &
TextBox1.Text & "' ", con)
            cmd.ExecuteNonQuery()
            dr = cmd.ExecuteReader
            MessageBox.Show("Record Updated", "Updated",
MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
        'Delete Record
        Try
            con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:UsersTiwariDesktopEmployee.mdb")
            con.Open()
            cmd = New OleDbCommand("delete from Emp where Ecode='" &
TextBox1.Text & "'", con)
            cmd.ExecuteNonQuery()
            dr = cmd.ExecuteReader
            MessageBox.Show("Record Deleted", "Deleted",
MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
        'Show Record
        Try
            con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:UsersTiwariDesktopEmployee.mdb")
            con.Open()
            cmd = New OleDbCommand("select * from Emp", con)
dr = cmd.ExecuteReader
            While dr.Read
                TextBox1.Text = dr(0)
                TextBox2.Text = dr(1)
                TextBox3.Text = dr(2)
                TextBox4.Text = dr(3)
                TextBox5.Text = dr(4)
            End While
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        Try
            con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:UsersTiwariDesktopEmployee.mdb")
            con.Open()
            cmd = New OleDbCommand("select * from Emp", con)
            dr = cmd.ExecuteReader
            While dr.Read
                ListBox1.Items.Add(dr(1))
            End While
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
        Application.Exit()
    End Sub
End Class

Weitere ähnliche Inhalte

Was ist angesagt?

Codes
CodesCodes
CodesOSit3
 
"Query Execution: Expectation - Reality (Level 300)" Денис Резник
"Query Execution: Expectation - Reality (Level 300)" Денис Резник"Query Execution: Expectation - Reality (Level 300)" Денис Резник
"Query Execution: Expectation - Reality (Level 300)" Денис РезникFwdays
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventasDAYANA RETO
 
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerVisual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerDarwin Durand
 
Reservasi hotel
Reservasi hotelReservasi hotel
Reservasi hoteldian pw
 
Excel to Use Rest API to communicate with a server
Excel to Use Rest API to communicate with a serverExcel to Use Rest API to communicate with a server
Excel to Use Rest API to communicate with a serverdocuboy
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)Darwin Durand
 
Ejercicios vb primer parcial
Ejercicios vb primer parcialEjercicios vb primer parcial
Ejercicios vb primer parcialJose Jimenez
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY GOKUL SREE
 
Change logon screen
Change logon screenChange logon screen
Change logon screendom_cruse
 
Url&doc html
Url&doc htmlUrl&doc html
Url&doc htmlakila m
 
AWS Atlanta meetup CloudFormation conditionals
AWS Atlanta meetup CloudFormation conditionals AWS Atlanta meetup CloudFormation conditionals
AWS Atlanta meetup CloudFormation conditionals Adam Book
 
Cross platform mobile development with visual studio and xamarin
Cross platform mobile development with visual studio and xamarinCross platform mobile development with visual studio and xamarin
Cross platform mobile development with visual studio and xamarinIbon Landa
 
Código Editor Net
Código Editor NetCódigo Editor Net
Código Editor Netcymbron
 

Was ist angesagt? (20)

Codes
CodesCodes
Codes
 
"Query Execution: Expectation - Reality (Level 300)" Денис Резник
"Query Execution: Expectation - Reality (Level 300)" Денис Резник"Query Execution: Expectation - Reality (Level 300)" Денис Резник
"Query Execution: Expectation - Reality (Level 300)" Денис Резник
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventas
 
Examplecode
ExamplecodeExamplecode
Examplecode
 
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerVisual Studio.Net - Sql Server
Visual Studio.Net - Sql Server
 
Reservasi hotel
Reservasi hotelReservasi hotel
Reservasi hotel
 
Excel to Use Rest API to communicate with a server
Excel to Use Rest API to communicate with a serverExcel to Use Rest API to communicate with a server
Excel to Use Rest API to communicate with a server
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
 
Ejercicios vb primer parcial
Ejercicios vb primer parcialEjercicios vb primer parcial
Ejercicios vb primer parcial
 
Quanlycanbo
QuanlycanboQuanlycanbo
Quanlycanbo
 
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY DOT NET LAB PROGRAM PERIYAR UNIVERSITY
DOT NET LAB PROGRAM PERIYAR UNIVERSITY
 
Ete programs
Ete programsEte programs
Ete programs
 
Change logon screen
Change logon screenChange logon screen
Change logon screen
 
Url&doc html
Url&doc htmlUrl&doc html
Url&doc html
 
AWS Atlanta meetup CloudFormation conditionals
AWS Atlanta meetup CloudFormation conditionals AWS Atlanta meetup CloudFormation conditionals
AWS Atlanta meetup CloudFormation conditionals
 
Correction s+ rie_vb
Correction s+ rie_vbCorrection s+ rie_vb
Correction s+ rie_vb
 
Cross platform mobile development with visual studio and xamarin
Cross platform mobile development with visual studio and xamarinCross platform mobile development with visual studio and xamarin
Cross platform mobile development with visual studio and xamarin
 
Código Editor Net
Código Editor NetCódigo Editor Net
Código Editor Net
 
Active Record
Active RecordActive Record
Active Record
 
ActiveRecord
ActiveRecordActiveRecord
ActiveRecord
 

Andere mochten auch

Good manners (1)
Good manners (1)Good manners (1)
Good manners (1)mommymj
 
Multimedia kajian tempatan
Multimedia kajian tempatanMultimedia kajian tempatan
Multimedia kajian tempatanmissnisa
 
Intergrated for signout2hangout Caraka 2013
Intergrated for signout2hangout Caraka 2013Intergrated for signout2hangout Caraka 2013
Intergrated for signout2hangout Caraka 2013Muhammad Hibatullah
 
CGCA: Transition to Home School
CGCA: Transition to Home SchoolCGCA: Transition to Home School
CGCA: Transition to Home Schooleeniarrol
 
Pikachu Verde e Amarelo: a saga da franquia Pokémon no Brasil
Pikachu Verde e Amarelo: a saga da franquia Pokémon no BrasilPikachu Verde e Amarelo: a saga da franquia Pokémon no Brasil
Pikachu Verde e Amarelo: a saga da franquia Pokémon no BrasilGabriela-Kurtz
 
20150627 九州男児が山形でリモートワークして分かったこと
20150627 九州男児が山形でリモートワークして分かったこと20150627 九州男児が山形でリモートワークして分かったこと
20150627 九州男児が山形でリモートワークして分かったことSeiji Akatsuka
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled PresentationAna Beatriz
 
Bigger Data For Your Budget
Bigger Data For Your BudgetBigger Data For Your Budget
Bigger Data For Your BudgetHortonworks
 
Portfolio Maitelavado
Portfolio MaitelavadoPortfolio Maitelavado
Portfolio MaitelavadoMaite
 
Pengaruh jenis media tanam
Pengaruh jenis media tanamPengaruh jenis media tanam
Pengaruh jenis media tanamcahjatilengger
 
MZ24-simple (dragged)
MZ24-simple (dragged)MZ24-simple (dragged)
MZ24-simple (dragged)AnneBellego
 
Persepsi guru-tentang-buku-teks
Persepsi guru-tentang-buku-teksPersepsi guru-tentang-buku-teks
Persepsi guru-tentang-buku-teksFelix Baskara
 
emediaIT - Mobility Solutions - 2011.03.01
emediaIT - Mobility Solutions - 2011.03.01emediaIT - Mobility Solutions - 2011.03.01
emediaIT - Mobility Solutions - 2011.03.01Venketash (Pat) Ramadass
 
Business communication (zayani)
Business communication (zayani)Business communication (zayani)
Business communication (zayani)hassan777898
 

Andere mochten auch (20)

Good manners (1)
Good manners (1)Good manners (1)
Good manners (1)
 
Digital Marketing
Digital MarketingDigital Marketing
Digital Marketing
 
Multimedia kajian tempatan
Multimedia kajian tempatanMultimedia kajian tempatan
Multimedia kajian tempatan
 
Intergrated for signout2hangout Caraka 2013
Intergrated for signout2hangout Caraka 2013Intergrated for signout2hangout Caraka 2013
Intergrated for signout2hangout Caraka 2013
 
CGCA: Transition to Home School
CGCA: Transition to Home SchoolCGCA: Transition to Home School
CGCA: Transition to Home School
 
Pikachu Verde e Amarelo: a saga da franquia Pokémon no Brasil
Pikachu Verde e Amarelo: a saga da franquia Pokémon no BrasilPikachu Verde e Amarelo: a saga da franquia Pokémon no Brasil
Pikachu Verde e Amarelo: a saga da franquia Pokémon no Brasil
 
20150627 九州男児が山形でリモートワークして分かったこと
20150627 九州男児が山形でリモートワークして分かったこと20150627 九州男児が山形でリモートワークして分かったこと
20150627 九州男児が山形でリモートワークして分かったこと
 
Untitled Presentation
Untitled PresentationUntitled Presentation
Untitled Presentation
 
Bigger Data For Your Budget
Bigger Data For Your BudgetBigger Data For Your Budget
Bigger Data For Your Budget
 
Rekod kehadiran kelab
Rekod kehadiran kelabRekod kehadiran kelab
Rekod kehadiran kelab
 
Caching By Nyros Developer
Caching By Nyros DeveloperCaching By Nyros Developer
Caching By Nyros Developer
 
My book of poems - Batu Klont
My book of poems - Batu KlontMy book of poems - Batu Klont
My book of poems - Batu Klont
 
3.1.1 rambu rambu penyusunan rpp tematik
3.1.1 rambu rambu penyusunan rpp tematik3.1.1 rambu rambu penyusunan rpp tematik
3.1.1 rambu rambu penyusunan rpp tematik
 
Portfolio Maitelavado
Portfolio MaitelavadoPortfolio Maitelavado
Portfolio Maitelavado
 
Ap feb scene
Ap feb sceneAp feb scene
Ap feb scene
 
Pengaruh jenis media tanam
Pengaruh jenis media tanamPengaruh jenis media tanam
Pengaruh jenis media tanam
 
MZ24-simple (dragged)
MZ24-simple (dragged)MZ24-simple (dragged)
MZ24-simple (dragged)
 
Persepsi guru-tentang-buku-teks
Persepsi guru-tentang-buku-teksPersepsi guru-tentang-buku-teks
Persepsi guru-tentang-buku-teks
 
emediaIT - Mobility Solutions - 2011.03.01
emediaIT - Mobility Solutions - 2011.03.01emediaIT - Mobility Solutions - 2011.03.01
emediaIT - Mobility Solutions - 2011.03.01
 
Business communication (zayani)
Business communication (zayani)Business communication (zayani)
Business communication (zayani)
 

Ähnlich wie Database Connectivity with Data Reader in Visual Basic .NET

Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaYusman Kurniadi
 
Imports System.Data.OleDb Public Class Form1 Dim connc As Ne.pdf
Imports System.Data.OleDb Public Class Form1     Dim connc As Ne.pdfImports System.Data.OleDb Public Class Form1     Dim connc As Ne.pdf
Imports System.Data.OleDb Public Class Form1 Dim connc As Ne.pdffantabulustredingco
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMSaraswathiRamalingam
 
Parameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple inputParameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple inputuanna
 
โครงการ 5 บท
โครงการ 5 บทโครงการ 5 บท
โครงการ 5 บทMareenaHahngeh
 
โครงการ 5 บท
โครงการ 5 บทโครงการ 5 บท
โครงการ 5 บทMareenaHahngeh
 
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdf
  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdfapnashop1
 
Putting dialog boxes to work
Putting dialog boxes to workPutting dialog boxes to work
Putting dialog boxes to workchunky.sarath
 
Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01mafv1976
 
Qtp Imp Script Examples
Qtp Imp Script ExamplesQtp Imp Script Examples
Qtp Imp Script ExamplesUser1test
 
A Matter Of Form: Access Forms to make reporting a snap (or a click)
A Matter Of Form: Access Forms to make reporting a snap (or a click)A Matter Of Form: Access Forms to make reporting a snap (or a click)
A Matter Of Form: Access Forms to make reporting a snap (or a click)Alan Manifold
 
Introtodotnet
IntrotodotnetIntrotodotnet
Introtodotnetrashmix
 

Ähnlich wie Database Connectivity with Data Reader in Visual Basic .NET (20)

Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhana
 
Imports System.Data.OleDb Public Class Form1 Dim connc As Ne.pdf
Imports System.Data.OleDb Public Class Form1     Dim connc As Ne.pdfImports System.Data.OleDb Public Class Form1     Dim connc As Ne.pdf
Imports System.Data.OleDb Public Class Form1 Dim connc As Ne.pdf
 
Ditec esoft C# project
Ditec esoft C# projectDitec esoft C# project
Ditec esoft C# project
 
Ditec esoft C# project
Ditec esoft C# project Ditec esoft C# project
Ditec esoft C# project
 
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAMPROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
PROGRAMMING USING C#.NET SARASWATHI RAMALINGAM
 
VB Dot net
VB Dot net VB Dot net
VB Dot net
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
Parameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple inputParameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple input
 
โครงการ 5 บท
โครงการ 5 บทโครงการ 5 บท
โครงการ 5 บท
 
โครงการ 5 บท
โครงการ 5 บทโครงการ 5 บท
โครงการ 5 บท
 
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdf
  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf  Imports System.Net.Sockets Imports System.Text Public Class Form1   .pdf
Imports System.Net.Sockets Imports System.Text Public Class Form1 .pdf
 
Putting dialog boxes to work
Putting dialog boxes to workPutting dialog boxes to work
Putting dialog boxes to work
 
Public class form1
Public class form1Public class form1
Public class form1
 
Public class form1
Public class form1Public class form1
Public class form1
 
Qtp launch
Qtp launchQtp launch
Qtp launch
 
Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01Sistemadeventas 100707084319-phpapp01
Sistemadeventas 100707084319-phpapp01
 
Qtp Imp Script Examples
Qtp Imp Script ExamplesQtp Imp Script Examples
Qtp Imp Script Examples
 
A Matter Of Form: Access Forms to make reporting a snap (or a click)
A Matter Of Form: Access Forms to make reporting a snap (or a click)A Matter Of Form: Access Forms to make reporting a snap (or a click)
A Matter Of Form: Access Forms to make reporting a snap (or a click)
 
Introtodotnet
IntrotodotnetIntrotodotnet
Introtodotnet
 

Mehr von Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi)

Mehr von Bosco Technical Training Society, Don Bosco Technical School (Aff. GGSIP University, New Delhi) (20)

String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
C Structure and Union in C
C Structure and Union in CC Structure and Union in C
C Structure and Union in C
 
Preprocessor Directive in C
Preprocessor Directive in CPreprocessor Directive in C
Preprocessor Directive in C
 
File Handling in C Programming
File Handling in C ProgrammingFile Handling in C Programming
File Handling in C Programming
 
Bit field enum and command line arguments
Bit field enum and command line argumentsBit field enum and command line arguments
Bit field enum and command line arguments
 
Pointers in C and Dynamic Memory Allocation
Pointers in C and Dynamic Memory AllocationPointers in C and Dynamic Memory Allocation
Pointers in C and Dynamic Memory Allocation
 
Array in C
Array in CArray in C
Array in C
 
C storage class
C storage classC storage class
C storage class
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
C Operators
C OperatorsC Operators
C Operators
 
C programming Basics
C programming BasicsC programming Basics
C programming Basics
 
Software Development Skills and SDLC
Software Development Skills and SDLCSoftware Development Skills and SDLC
Software Development Skills and SDLC
 
Mobile commerce
Mobile commerceMobile commerce
Mobile commerce
 
E commerce application
E commerce applicationE commerce application
E commerce application
 
Data normalization
Data normalizationData normalization
Data normalization
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
Security issue in e commerce
Security issue in e commerceSecurity issue in e commerce
Security issue in e commerce
 
ER to Relational Mapping
ER to Relational MappingER to Relational Mapping
ER to Relational Mapping
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 

Kürzlich hochgeladen

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Kürzlich hochgeladen (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Database Connectivity with Data Reader in Visual Basic .NET

  • 1. Database Connectivity with Data Reader Figure 17.5 Step 1.Create a database Employee in Ms Access 2003/2007/2010/2013 and then create a table Emp. Field of EMP table is: Ecode, Ename, Eage, Edesig, and Esalary. Now adding the data into the table. Step 2. Open Visual Studio .Net 2008/2010/2012. Step 3. Click on view menu and open server explorer. Step 4. Right click on data connections then select add connection. Now select data source Microsoft Access Database file and then select the database file name. Where the database is stored and then click ok button. Step 5. When the connection is created then copy the path of file in properties window. Path is this: "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:UsersTiwariDesktopEmployee.mdb") Then design a form, coding in a form and then run it. Example 15.2 Imports System.Data.OleDb Public Class Form2 Dim con As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() TextBox4.Clear() TextBox5.Clear() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Save Record Try
  • 2. con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:UsersTiwariDesktopEmployee.mdb") con.Open() cmd = New OleDbCommand("insert into Emp values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "') ", con) cmd.ExecuteNonQuery() MessageBox.Show("Record Inserted", "Updated", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'Update Record Try con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:UsersTiwariDesktopEmployee.mdb") con.Open() cmd = New OleDbCommand("Update Emp set Ecode='" & TextBox1.Text & "',Ename='" & TextBox2.Text & "',Eage='" & TextBox3.Text & "',Edesig='" & TextBox4.Text & "', Esalary= '" & TextBox5.Text & "' where Ecode='" & TextBox1.Text & "' ", con) cmd.ExecuteNonQuery() dr = cmd.ExecuteReader MessageBox.Show("Record Updated", "Updated", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Delete Record Try con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:UsersTiwariDesktopEmployee.mdb") con.Open() cmd = New OleDbCommand("delete from Emp where Ecode='" & TextBox1.Text & "'", con) cmd.ExecuteNonQuery() dr = cmd.ExecuteReader MessageBox.Show("Record Deleted", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click 'Show Record Try con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:UsersTiwariDesktopEmployee.mdb") con.Open() cmd = New OleDbCommand("select * from Emp", con)
  • 3. dr = cmd.ExecuteReader While dr.Read TextBox1.Text = dr(0) TextBox2.Text = dr(1) TextBox3.Text = dr(2) TextBox4.Text = dr(3) TextBox5.Text = dr(4) End While Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:UsersTiwariDesktopEmployee.mdb") con.Open() cmd = New OleDbCommand("select * from Emp", con) dr = cmd.ExecuteReader While dr.Read ListBox1.Items.Add(dr(1)) End While Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Application.Exit() End Sub End Class