Private Sub btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
Try
txtmsg.Text = ""
OleDbDataAdapter1 = New OleDbDataAdapter("select * from phbook where name like '" & ddl.SelectedItem.Text & "%'", OleDbConnection1)
OleDbDataAdapter1.Fill(DataSet21, "phbook")
OleDbConnection1.Open()
Dim com As New OleDbCommand
com.Connection = OleDbConnection1
com.CommandText = "select * from phbook"
dg1.DataBind()
Catch ex As Exception
txtmsg.Text = ex.ToString
OleDbConnection1.Close()
End Try
End Sub


i was tried this code to my application for search record form database.But got syntax error on ddl.selecteditem.text .

can anyone teach me how to make this code usefull to my application.
tq

Use ddl.SelectedValue.ToString

Use ddl.SelectedValue.ToString

still doesn't works. can u paste here what u have done.

Please paste your exception here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.