Sulieman Alkatib

Sulieman Alkatib

  • NA
  • 56
  • 4.3k

use DataSet and table Adapter

May 23 2017 4:59 AM
It's my first time to use dataset and table adapter. I'm trying to make insert , view all records and search for specific record in VB.
 
There is no errors but non of the buttons works
 
anyone have an idea how to make this work ?
also I wand the table to be refreshed every time I insert a record 
  1. Imports System.Data.SqlClient  
  2.   
  3. Public Class Form1  
  4.   
  5.     Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
  6.         Me.Product_masterTableAdapter.Fill(Me.DBDataSet.Product_master)  
  7.         InitializeComponent()  
  8.   
  9.   
  10.   
  11.     End Sub  
  12.   
  13.   
  14.     Private Sub Button3_Click(ByVal sender As System.ObjectByVal e As System.EventArgs)  
  15.         'to search for record by product number  
  16.         Dim search As String = TextBox1.Text  
  17.         Try  
  18.   
  19.   
  20.             Me.Product_masterTableAdapter.FillBysearch(Me.DBDataSet.Product_master, search)  
  21.             InitializeComponent()  
  22.         Catch  
  23.         End Try  
  24.   
  25.   
  26.     End Sub  
  27.   
  28.     Private Sub Button4_Click(ByVal sender As System.ObjectByVal e As System.EventArgs)  
  29.   
  30.         'to display all records  
  31.         Me.Product_masterTableAdapter.Fill(Me.DBDataSet.Product_master)  
  32.   
  33.         InitializeComponent()  
  34.     End Sub  
  35.   
  36.   
  37.   
  38.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click  
  39.         Dim pdt As Integer  
  40.         Dim desc As String = ""  
  41.         Dim pro As Integer  
  42.         Dim uni As String = ""  
  43.         Dim qty As Integer  
  44.         Dim rec As Integer  
  45.         Dim cos As Integer  
  46.         Dim sel As Integer  
  47.   
  48.         Me.Product_masterTableAdapter.InsertQuery(pdt_no:=pdt, descr:=desc, profit_percent:=pro, uni_measure:=uni, qty_on_hand:=qty, recorder_level:=rec, cost_price:=cos, sell_price:=sel)  
  49.   
  50.         Label9.Text = "Product inserted"  
  51.     End Sub  
  52. End Class  
 

Answers (1)