Monday, April 23, 2012

How to connect to MS- Access in VB.net


Dim conn As New OleDb.OleDbConnection
         conn.ConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Love.mdb"
        Try
             conn.Open()

        Catch ex As Exception
            MessageBox.Show(ex.Message, "connection to access failed")

        End Try
 Dim comm As New OleDb.OleDbCommand

  comm.CommandText = "delete from customer where ID = " & TextBox1.Text

         comm.Connection = conn

        If  comm.ExecuteNonQuery() = 1 Then
            MessageBox.Show("Successful")
        End If


         comm.CommandText = "select ID from customer where contact = '" & TextBox3.Text & "'"
         comm.Connection = conn

        Dim dr As OleDb.OleDbDataReader =  comm.ExecuteReader()

        If dr.HasRows Then
            Do While dr.Read()
                MessageBox.Show("The Customer id is " & dr("ID"))
            Loop

        End If


       conn.Close()


8 comments:

  1. Replies
    1. You can visit www.goapti.in for the more live and mock interviews.

      Delete
  2. You can also visit www.goapti.in for Aptitude and Interview Preparations.

    ReplyDelete
  3. Hey ,

    Great Job . You Know what ?

    I read a lot of blog posts and I never heard of such a topic. I love the subject you have done about bloggers. Very simple. I am also writing a blog related to the malta work permit. You can also see this.

    ReplyDelete
  4. What a fantastic post! This is so chock full of useful information I can't wait to dig deep and start utilizing the resources you have given me. your exuberance is refreshing

    you've outdone yourself this time

    This is probably the best, most concise step-by-step guide I've ever seen on how to build a successful blog. i am also writing blog about the kindly review it online english speaking classes for kids.

    ReplyDelete
  5. What an awesome post! This is so crammed with helpful data I can hardly wait to burrow profound and begin using the assets you have given me. your abundance is invigorating

    you've done something extraordinary for yourself this time

    This is presumably the awesome, brief bit by bit direct I've at any point seen on the most proficient method to construct a fruitful blog. I'm likewise composing blog about the kindly audit it. french language institute in delhi .

    ReplyDelete