Database
Where is the database file......?
'the dataset and update the datasource Dim da As New OleDb.OleDbDataAdapter 'declare some SQL statements Dim sql As String = "SELECT ItemID as [ID], itemname as [Item Name],itemdescription as [Description],itemremarks," & _ "itembarcodeno, itemcategory, itemnoqty FROM tblitemmaster;" Try 'open the connection con.Open() With cmd .Connection = con .CommandText = sql End With 'get the SQL statements used to select records in the datasource da.SelectCommand = cmd 'it fills the datatable da.Fill(publictable) 'populate the datagridview itemdatagrid.DataSource = publictable Catch ex As Exception End Try
Private Sub itemdatagrid_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles itemdatagrid.CellClick lblitemkey.Text = itemdatagrid.CurrentRow.Cells(0).Value.ToString txtitemname.Text = itemdatagrid.CurrentRow.Cells(1).Value.ToString txtitemdescription.Text = itemdatagrid.CurrentRow.Cells(2).Value.ToString txtitemremarks.Text = itemdatagrid.CurrentRow.Cells(3).Value.ToString txtitembarcode.Text = itemdatagrid.CurrentRow.Cells(4).Value.ToString cbcategory.SelectedValue = itemdatagrid.CurrentRow.Cells(5).Value.ToString End Sub
'we declare cmd to represent an SQL Statements or a stored procedure 'to execute against a data source Dim cmd As New OleDb.OleDbCommand Dim sql As String = "UPDATE tblitemmaster SET itemname = '" & txtitemname.Text & "'," & _ " itemdescription = '" & txtitemdescription.Text & "', " & _ " itemremarks = '" & txtitemremarks.Text & "', itembarcodeno = '" & txtitembarcode.Text & "', " & _ " itemcategory = '" & cbcategory.SelectedItem & "', itemnoqty = '" & Val(txtnumqty.Text) & "', " & _ " where itemID = " & lblitemkey.Text & "" Dim result As Integer Try con.Open() With cmd .Connection = con .CommandText = Sql result = cmd.ExecuteNonQuery If result = 0 Then Else Call btnitemload_Click(sender, e) End If End With Catch ex As Exception End Try
Dim cmd As New OleDb.OleDbCommand Dim sql As String = "Delete * from tblitemmaster where itemID= " & lblitemkey.Text & "" Dim result As Integer Try con.Open() With cmd .Connection = con .CommandText = sql result = cmd.ExecuteNonQuery If result = 0 Then Else Call btnitemload_Click(sender, e) End If End With Catch ex As Exception End Try