hye....i have a data in access 2007 which is:

table1
ID DOCUMENTNAME PAGE
1 investment 2000 12
2 investment 1989 4
3 investment march 15

how to display the id and page when user typing the document name in combobox..using vb.net 2008

Hi,

Specify what you want ??? Lol

ok..i have the data in access 2007 as above..what i want is the code to read and display the data in vb.net..

i.e..when i type "investment 2000" in the combobox and press search button it will display the ID number and the PAGE in textbox..

Use following code

Private Sub show_invesment()

        Dim conn As New OleDbConnection

        Dim dbConn As OleDbConnection
        Dim dbCommand As New OleDbCommand

        dbConn = New OleDbConnection(cnSettings())
        dbCommand.CommandText = "SELECT * FROM [table11] Where invesment2000 = '" & combobox1.Text & "'"
        
        dbCommand.Connection = dbConn
        dbConn.Open()

        Dim dbDR As OleDb.OleDbDataReader = dbCommand.ExecuteReader

        Try
            While dbDR.Read
                Dim label2 As New Label
                Dim label4 As New Label
                Me.Label2.Text = CStr(dbDR("ID number"))
                Me.Label4.Text = CStr(dbDR("PAGE in"))
            End While
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
        Finally
            dbConn.Close()
        End Try
    End Sub

Keep in mind that there is no space between ID number and PAGE in
Try this and inform me......

hye vasim jada..thanks for the code..have a problem where:

dbConn = New OleDbConnection(cnSettings())--> not declare
dbConn.Open() -->The ConnectionString property has not been initialized.

is there possible if i use module to connect with my data?like this:

Imports System.Data.OleDb
Module Module1
    Public acsconn As New OleDbConnection
    Public acsdr As OleDbDataReader
    Public strsql As String
    Sub connect()
        acsconn.ConnectionString = "provider= microsoft.ace.oledb.12.0; data source= |datadirectory|\database8.accdb;"
        acsconn.Open()

    End Sub
End Module

can you give any idea please

'Its because dbConn is not declared you may solved it by declaring it like: 
'Dim dbConn as New Oledb.OledbConnection

dbConn = New OleDbConnection(cnSettings())--> not declare


'Not been initialized because you dont have yer propery declare your variable and not yet connect it with database 
dbConn.Open() -->The ConnectionString property has not been initialized.

Problem is solved or not ? if not then post your problem facing.

still have a problem..but its ok..im now working on a new code and project..tq!

USE PROPERTY and set AutoCompleteMode AS 'Sujjest Append' ANd 1 another AutoCompleteSource AS 'ListItems'

this will help u out

Just a question...Why are you declaring two connections?

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.