|  |  | 
            
              | ของผมมีปัญหาเหมือนกันคับ ส่งค่าไปค้นหาแล้วไม่เจอมัน ERROR คับ แต่ถ้าเจอทำงานได้ตามปกติ code ผมเป็นแบบนี้คับ
 Code (VB.NET)
 
  Private Sub txtfg_code_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtfg_code.KeyDown
        If e.KeyCode = Keys.Enter Then
            If txtOrder_id.Text.Trim() = "" Then
                txtOrder_id.Text = "0"
                Return
            End If
            If txt_counter.Text.Trim() = "" Then
                txt_counter.Focus()
                Return
            End If
            If txtfg_code.Text.Trim() = "" Then
                txtfg_code.Focus()
                Return
            End If
            Try
                sb.Remove(0, sb.Length)
                sb.Append("select*from in_goods_counter  where counter=@counter and code =@code")
                Dim sqlingoods As String = sb.ToString()
                Dim com As New SqlCommand
                With com
                    .CommandType = CommandType.Text
                    .CommandText = sqlingoods
                    .Connection = con
                    .Parameters.Clear()
                    .Parameters.Add("@counter", SqlDbType.VarChar).Value = txt_counter.Text.Trim()
                    .Parameters.Add("@code", SqlDbType.VarChar).Value = txtfg_code.Text.Trim()
                    dr = .ExecuteReader()
                    If dr.HasRows Then
                        dt = New DataTable
                        dt.Load(dr)
                        Dim CORP, CODE, NAME, OLD_PRICE, PRICE As String
                        Dim Amount As Integer = 1
                        CORP = dt.Rows(0)("counter").ToString()
                        CODE = dt.Rows(0)("code").ToString()
                        NAME = dt.Rows(0)("name").ToString()
                        OLD_PRICE = dt.Rows(0)("old_price").ToString()
                        PRICE = dt.Rows(0)("price").ToString()
                        With DataGridView1.ColumnHeadersDefaultCellStyle
                            .BackColor = Color.Navy
                            .ForeColor = Color.White
                            .Font = New Font(DataGridView1.Font, FontStyle.Bold)
                        End With
                        Me.DataGridView1.Rows.Add(CORP, CODE, OLD_PRICE, PRICE, Amount, Nothing, NAME)
                        txtfg_code.Text = ""
                    Else
                        Dim CODE, NAME, OLD_PRICE, PRICE As String
                        Dim Amount As Integer = 1
                        Dim selectRow As DataRow
                        Dim fmshow As New fmshowsale
                        fmshowsale.ShowDialog()
                        selectRow = fmshowsale.selectRow
                       
  มันERROR ตรงนี้ครับ-->     CODE = CStr(selectRow.ItemArray(1))
                        NAME = CStr(selectRow.ItemArray(2))
                        OLD_PRICE = CStr(selectRow.ItemArray(4))
                        PRICE = CStr(selectRow.ItemArray(5))
                      
                        DataGridView1.Rows.Add(txt_counter.Text, CODE, OLD_PRICE, PRICE, Amount, Nothing, NAME)
                        txtfg_code.Text = ""
                        selectRow.Table.Clear()
                    End If
                    dr.Close()
                End With
                CalculateNet()
                CalculateNet1()
                CalculateNet2()
            Catch ex As Exception
                MessageBox.Show("ความผิดผลาด " + ex.Message, "รายงานความผิดผลาด", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return
            End Try
        End If
    End Sub
 |  
              | 
 ประวัติการแก้ไข
 2011-09-23 10:16:49
 2011-09-23 10:22:07
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-09-23 10:16:24 | By :
                            Testprogram |  |  |  
                  |  |  |  |  |  |  |