Click here to Skip to main content
16,021,432 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
 am working on a stock management system and i added textbox with autocomplete codes..i have two forms one is items form and other is stock in. now i can able to get itemcodeID from stockin itemnumber textbox with autocomplete codes but when i select that item number its not giving me the description..i mean to say that if user search itemcode in stock in form then he should get description and quantity of that item automatically... i am using vb.net and ms sql .

What I have tried:

<pre>Private Sub getData(ByVal dataCollection As AutoCompleteStringCollection)
    Dim connetionString As String = Nothing
    Dim connection As SqlConnection
    Dim command As SqlCommand
    Dim adapter As New SqlDataAdapter()
    Dim ds As New DataSet()



    connetionString = ("Server= DESKTOP-QN6F623; Database = dbo_main;Integrated Security = false;User ID=dis;Password=0m3rP@ss")
    Dim sql As String = "SELECT itemnumber FROM items"
    connection = New SqlConnection(connetionString)
    Try
        connection.Open()
        command = New SqlCommand(sql, connection)
        adapter.SelectCommand = command
        adapter.Fill(ds)
        adapter.Dispose()
        command.Dispose()
        connection.Close()
        For Each row As DataRow In ds.Tables(0).Rows
            dataCollection.Add(row(0).ToString())
        Next
    Catch ex As Exception
        MessageBox.Show("Can not open connection ! ")



    End Try

End Sub


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

    Stockin_itemnumberTextBox.AutoCompleteMode = AutoCompleteMode.Suggest
    Stockin_itemnumberTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource
    Dim DataCollection As New AutoCompleteStringCollection()
    getData(DataCollection)
    Stockin_itemnumberTextBox.AutoCompleteCustomSource = DataCollection




End Sub
Posted
Updated 31-Dec-18 1:35am

1 solution

You aren't retrieving the description or stock level of any items; just the itemnumber.
The system can't work out for you that you want more info: you have to tell it what you want to display where.
In this case, you probably want to handle the TextChanged event of the TextBox, and use the itemnumber in its Text property to rescan the DB and fetch the description and current stock level. You can then display these wherever you want.
 
Share this answer
 
Comments
Member 12654313 31-Dec-18 8:47am    
ok i understand your point but can you write any code for me please that can help me in autocomplete and fetch the description ..... that will be great help for me ...happy new year
OriginalGriff 31-Dec-18 9:02am    
How do you expect me to write code for you when I have no access to your code or DB and no idea how it is all organised?

This isn't complicated: if it's your job then you should be more than capable of doing it. If you are a student, then you should consult your course notes and learn how to do it! :laugh:
Member 12654313 1-Jan-19 0:25am    
nope i am not a student i am IT engineer in uae. i have idea to do this but i thought maybe if i write any additional line or code in my code then maybe it work the way i want.
OriginalGriff 1-Jan-19 1:51am    
So do: you are a trained professional, so you should know how to handle an event, and what to do with a DB!

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