Hi i tried the same.. but its not displaying any data from database

Public Class Editdetails

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim cn As New System.Data.OleDb.OleDbConnection

        Dim cm As New System.Data.OleDb.OleDbCommand

        Dim form As New Fielddetails

        Dim rd As System.Data.OleDb.OleDbDataReader

        Dim tbl_name As String = "Fld_detail_" & Datamaker.Application_Datamaker_ListBox.SelectedItem

        cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\175943\Desktop\database1.accdb;Persist Security Info=False;"

        Try
            cn.Open()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        cm.Connection = cn
        cm.CommandText = "select * from (" & tbl_name & ") where Start_loc like '" & form.ListBox_Fielddetails.SelectedItem & "%'"
        rd = cm.ExecuteReader()
        While rd.Read

            Me.datatype.SelectedItem = rd("Datatype").ToString
            Me.fieldname.Text = rd("Field_var").ToString


        End While
        rd.Close()

    End Sub

Recommended Answers

All 2 Replies

>but its not displaying any data from database.

Use * instead of %.

cm.CommandText = "select * from (" & tbl_name & ") where Start_loc like '" & form.ListBox_Fielddetails.SelectedItem & "*'"

Changed but still same proble:-(

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.