Imports System.Data.OleDb
Public Class Form1
Dim conn As New OleDbConnection
Dim comm As New OleDbCommand
Dim dreader As OleDbDataReader
Dim str As String = ""
Dim wheelbase As String
Function CreateconnString(ByVal Str As String) As String
Return "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Str + ";Extended Properties=""Excel 8.0;HDR=YES;"""
End Function
Private Sub SEARCH_Click(sender As Object, e As EventArgs) Handles SEARCH.Click
wheelbase = "wheelbase"
conn.ConnectionString = CreateconnString("C:\Users\shshaik\Desktop\sample.xlsx")
comm.Connection = conn
comm.CommandText = "SELECT * FROM [Sheet1$] where name= " & Chr(39) & wheelbase & Chr(39)
conn.Open()
dreader = comm.ExecuteReader(CommandBehavior.CloseConnection)
End Sub
End Class
** when i click the search button in my form giving the serial no the data which is present in the excel sheet should appear in the respective text boxes of the userform in vb..**