Private Sub Product_Details1(ByVal pid1 As String)
Dim n As Integer
n = 0
DataGridView1.Rows.Clear()
myConnection = New SqlConnection(connectionstring)
myConnection.Open()
Try
sqlcmd = New SqlCommand("SELECT P_Id,P_Selling_Price FROM Product_Details WHERE P_Id='" & ComboBox1.SelectedText & "' ", myConnection)
Dim dr As SqlDataReader = sqlcmd.ExecuteReader
If dr.HasRows Then
While dr.Read()
DataGridView1.Rows.Add()
DataGridView1.Rows(n).Cells(0).Value = dr("P_Id").ToString
DataGridView1.Rows(n).Cells(1).Value = dr("P_Selling_Price").ToString
DataGridView1.Rows(n).Cells(2).Value = TextBox1.Text
DataGridView1.Rows(n).Cells(3).Value = Val(DataGridView1.Rows(n).Cells(2).Value) * Val(DataGridView1.Rows(n).Cells(1).Value)
n += 1
End While
Else
MessageBox.Show("Data doesn't exits !!", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
End If
sqlcmd.Cancel()
dr.Close()
myConnection.Close()
Catch ex As Exception
End Try
End Sub
the data is not takin from either from tables or textbox
the message is dsplay as Data doesn't exits
this is the coding to enter button to transfer the data from textbox and table to datagridview
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pid As String = ComboBox1.SelectedItem
myConnection = New SqlConnection(Module1.connectionString)
myConnection.Open()
newq.Text = Val(TextBox2.Text) - Val(TextBox1.Text)
Dim majortable As SqlCommand = New SqlCommand("Update Product_Details Set Quantity ='" & newq.Text & "' WHERE P_ID='" & ComboBox1.SelectedItem & " '", myConnection)
majortable.ExecuteNonQuery()
MessageBox.Show("Changes had done suceesfully. !", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
myConnection.Close()
Product_Details1(pid)
refreshComponents()
End Sub