I'm looking for a way to create a lookup textbox using VISUAL BASIC 2008

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CodeJoker
    New Member
    • Jan 2010
    • 2

    I'm looking for a way to create a lookup textbox using VISUAL BASIC 2008

    I am a beginner at programming no classes it's sel study with e-books but hey everyone gets stuck. . . I have a snippet of code that I need someone to revise and if possible advice on sorting out my problem, I created a textbox to lookup values in my DB but for sum reason it does'nt matter what I type I seem to get the same value everytime. . . . .Fly by the code and see if anyone could help.

    Private m_cnADONetConne ction As New OleDb.OleDbConn ection()
    Private m_daDataAdapter As OleDb.OleDbData Adapter
    Private m_cbCommandBuil der As OleDb.OleDbComm andBuilder
    Private m_dtCD As New DataTable
    Dim m_rowPosition As Integer = 0

    Private Sub StockDetailsFor m_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
    m_cnADONetConne ction.Connectio nString = _
    "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=C:\TEST. mdb"

    m_cnADONetConne ction.Open()

    m_daDataAdapter = New OleDb.OleDbData Adapter("Select * From CD", m_cnADONetConne ction)
    m_cbCommandBuil der = New OleDb.OleDbComm andBuilder(m_da DataAdapter)
    m_daDataAdapter .Fill(m_dtCD)


    Public Sub StockCheck()

    StockEdit_Open_ Conn()
    Dim sql = "SELECT CouplingCode ,AlbumTitle ,ReleaseDate ,TotalSongs ,PPD FROM CD WHERE CouplingCode='" & StockDetailsFor m.txtSearch.Tex t & "'"
    Dim cmd As New System.Data.Ole Db.OleDbCommand

    cmd = New OleDbCommand(sq l, m_cnADONetConne ction)
    Dim exReader As OleDbDataReader = cmd.ExecuteRead er
    m_cbCommandBuil der = New OleDb.OleDbComm andBuilder(m_da DataAdapter)


    Private Sub txtSearch_Leave (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles txtSearch.Leave

    Try
    If exReader.Read = False Then
    MessageBox.Show ("Stock Item does not exist", "Stock Item Error", MessageBoxButto ns.OK, MessageBoxIcon. Stop)
    m_cnADONetConne ction.Close()
    m_cnADONetConne ction.Dispose()
    Else
    StockDetailsFor m.CouplingCodeI D.Text = _
    m_dtCD.Rows(m_r owPosition)("Co uplingCode").To String()
    StockDetailsFor m.txtAlbumName. Text = _
    m_dtCD.Rows(m_r owPosition)("Al bumTitle").ToSt ring()
    StockDetailsFor m.txtPPD.Text = _
    m_dtCD.Rows(m_r owPosition)("PP D").ToString ()
    StockDetailsFor m.txtTotalSongs .Text = _
    m_dtCD.Rows(m_r owPosition)("To talSongs").ToSt ring()
    StockDetailsFor m.dtpReleaseDat e.Text = _
    m_dtCD.Rows(m_r owPosition)("Re leaseDate").ToS tring()
    StockDetailsFor m.txtQtyHand.Te xt = _
    m_dtCD.Rows(m_r owPosition)("Qt yOnHand").ToStr ing()
    End If
    End Sub
  • vb5prgrmr
    Recognized Expert Contributor
    • Oct 2009
    • 305

    #2
    wrong forum... this forum is pre .net tech, i.e. classic visual basic, you need .net...

    Comment

    Working...