Click here to Skip to main content
15,892,005 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: how can i make Infix to postfix w/ tabulation method using Visual studio 2010? Pin
Dave Kreskowiak28-Sep-13 18:05
mveDave Kreskowiak28-Sep-13 18:05 
QuestionThe best way to handle a VERY Large array of strings Pin
Kryptex28-Sep-13 16:48
Kryptex28-Sep-13 16:48 
GeneralRe: The best way to handle a VERY Large array of strings Pin
PIEBALDconsult28-Sep-13 17:14
mvePIEBALDconsult28-Sep-13 17:14 
AnswerRe: The best way to handle a VERY Large array of strings Pin
Dave Kreskowiak28-Sep-13 18:04
mveDave Kreskowiak28-Sep-13 18:04 
AnswerRe: The best way to handle a VERY Large array of strings Pin
Abhinav S28-Sep-13 20:11
Abhinav S28-Sep-13 20:11 
AnswerRe: The best way to handle a VERY Large array of strings Pin
David Mujica30-Sep-13 3:17
David Mujica30-Sep-13 3:17 
AnswerRe: The best way to handle a VERY Large array of strings Pin
Kryptex7-Oct-13 4:02
Kryptex7-Oct-13 4:02 
QuestionPopulate Data form MySQL Database Table in Datagridview by Datagridview autocomplete Textbox cell Pin
Biplob Singha Shee26-Sep-13 21:37
Biplob Singha Shee26-Sep-13 21:37 
Hi all,

I have made a datagridview textbox cell autocomplete. Now I want to get the values in the other cell associated with the autocomplete textbox cell from the database.

Like I have 4 Columns in my datagridview.

Col0 is ProductId (Primary Key)
Col1 is ProductName (Autocomplete)
Col2 is AvailableQty
Col3 is Rate

When I select the product from Col1 by Up or Down key, the other column cells would populate the data associated with the productname(Col1) from the database.

My question is how would I do that ?

I tried...

VB
Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
        If DataGridView1.CurrentCell.Value Is Nothing Then
            '// Do Nothing
        Else
            Try
                OpenConnection()
                Dim Sb1 As New StringBuilder
                Sb1.Append("SELECT * FROM stockitems WHERE ProductName='" & Me.DataGridView1.CurrentRow.Cells(1).Value & "'")
                Dim dbcommand As New MySqlCommand
                dbcommand.Connection = conn
                dbcommand.CommandText = Sb1.ToString
                Dim dbread As MySqlDataReader = dbcommand.ExecuteReader
                While dbread.Read
                    DataGridView1.CurrentRow.Cells(0) = dbread("ProductId")
                    DataGridView1.CurrentRow.Cells(2) = dbread("AvailableQty")
                    DataGridView1.CurrentRow.Cells(3) = dbread("Rate")
                End While
                dbread.Close()
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally
                CloseConnection()
            End Try
        End If
    End Sub

But nothing happened.
Then I tried...

VB
Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
        If e.KeyCode = Keys.Down Then
            Try
                OpenConnection()
                Dim Sb1 As New StringBuilder
                Sb1.Append("SELECT * FROM stockitems WHERE ProductName='" & Me.DataGridView1.CurrentRow.Cells(1).Value & "'")
                Dim dbcommand As New MySqlCommand
                dbcommand.Connection = conn
                dbcommand.CommandText = Sb1.ToString
                Dim dbread As MySqlDataReader = dbcommand.ExecuteReader
                While dbread.Read
                    DataGridView1.CurrentRow.Cells(0) = dbread("ProductId")
                    DataGridView1.CurrentRow.Cells(2) = dbread("AvailableQty")
                    DataGridView1.CurrentRow.Cells(3) = dbread("Rate")
                End While
                dbread.Close()
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally
                CloseConnection()
            End Try
        End If
    End Sub


But I failed.

Please help...
GeneralRe: Populate Data form MySQL Database Table in Datagridview by Datagridview autocomplete Textbox cell Pin
Biplob Singha Shee27-Sep-13 19:24
Biplob Singha Shee27-Sep-13 19:24 
GeneralRe: Populate Data form MySQL Database Table in Datagridview by Datagridview autocomplete Textbox cell Pin
Richard MacCutchan27-Sep-13 21:23
mveRichard MacCutchan27-Sep-13 21:23 
GeneralADODB recordset not returning case-sensitive results Pin
Member 1026522824-Sep-13 9:07
Member 1026522824-Sep-13 9:07 
GeneralRe: ADODB recordset not returning case-sensitive results Pin
Dave Kreskowiak24-Sep-13 12:12
mveDave Kreskowiak24-Sep-13 12:12 
GeneralRe: ADODB recordset not returning case-sensitive results Pin
Member 1026522825-Sep-13 5:33
Member 1026522825-Sep-13 5:33 
GeneralRe: ADODB recordset not returning case-sensitive results Pin
Dave Kreskowiak25-Sep-13 7:57
mveDave Kreskowiak25-Sep-13 7:57 
GeneralRe: ADODB recordset not returning case-sensitive results Pin
TnTinMn25-Sep-13 13:34
TnTinMn25-Sep-13 13:34 
GeneralRe: ADODB recordset not returning case-sensitive results Pin
Member 1026522826-Sep-13 4:51
Member 1026522826-Sep-13 4:51 
GeneralRe: ADODB recordset not returning case-sensitive results Pin
Member 1026522826-Sep-13 6:07
Member 1026522826-Sep-13 6:07 
QuestionSelect Audio Track Pin
Andre.Adrian23-Sep-13 0:32
professionalAndre.Adrian23-Sep-13 0:32 
AnswerRe: Select Audio Track Pin
Dave Kreskowiak23-Sep-13 1:23
mveDave Kreskowiak23-Sep-13 1:23 
GeneralRe: Select Audio Track Pin
Brisingr Aerowing24-Sep-13 11:39
professionalBrisingr Aerowing24-Sep-13 11:39 
GeneralRe: Select Audio Track Pin
Dave Kreskowiak24-Sep-13 12:05
mveDave Kreskowiak24-Sep-13 12:05 
JokeRe: Select Audio Track Pin
Brisingr Aerowing24-Sep-13 14:23
professionalBrisingr Aerowing24-Sep-13 14:23 
GeneralRe: Select Audio Track Pin
Dave Kreskowiak24-Sep-13 15:45
mveDave Kreskowiak24-Sep-13 15:45 
GeneralRe: Select Audio Track Pin
Andre.Adrian25-Sep-13 23:42
professionalAndre.Adrian25-Sep-13 23:42 
QuestionCurrency Round Off Pin
Biplob Singha Shee22-Sep-13 4:09
Biplob Singha Shee22-Sep-13 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.