Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Imports System.Data.OleDb
Public Class Form7
Dim cn As New OleDbConnection
Dim cm As New OleDbCommand
Dim qry As String = ""
Private Sub Form7_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;data source =E:\FINALYRPROJECT.xlsx;extended properties=excel 12.0;"
cn.Open()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
qry = "SELECT * FROM [student$] WHERE DOMAIN = CLOUD"
With cm
.Connection = cn
.CommandText = qry
Dim rdr As OleDbDataReader
rdr = cm.ExecuteReader

While rdr.Read()
ComboBox1.Items.Add(rdr(0).ToString)
End While
rdr.Close()
End With
ComboBox1.AutoCompleteSource = AutoCompleteSource.ListItems
ComboBox1.SelectedIndex = 0

End Sub
End Class
Posted
Comments
Mohi@priya 23-Aug-15 11:55am    
qry = "SELECT * FROM [student$] WHERE DOMAIN = CLOUD" instead of this line ,if i give
qry = "SELECT * FROM [student$] WHERE DOMAIN = TextBox1.Text",i am getting an error OleDbException was unhandled
No value given for one or more required parameters.i need an output in combobox like if i give a name in textbox,it's corresponding rollno,domain etc should be displayed

1 solution

How Can I Display A Particular Record Using Textbox ?

I did not find any textbox in your code. What do you want to display in textbox


I am getting oledb exception error

In which line you are getting this error. Use try Catch to catch the error
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900