'Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection("provider=sqloledb;user id=sa;password=;data source=127.0.0.1;initial catalog=northwind")
'con.Open()
'Dim com As New OleDb.OleDbCommand("select * from employees", con)
'Dim dr As OleDb.OleDbDataReader
'dr = com.ExecuteReader()
'Do While dr.Read
'ListBox1.Items.Add(dr.Item("lastname"))
'Loop
'dr.Close()
Dim con As OleDb.OleDbConnection = New OleDb.OleDbConnection("provider=sqloledb;user id=sa;password=;data source=t01;initial catalog=northwind")
'con.Open()
Dim com As New OleDb.OleDbCommand("select * from employees")
Dim com1 As New OleDb.OleDbCommand("select * from customers")
Dim da As New OleDb.OleDbDataAdapter(com.CommandText, con)
Dim ds As New DataSet()
da.Fill(ds, "emp")
Dim i As Integer = ds.Tables("emp").Rows.Count - 1
Do While i
ListBox1.Items.Add(ds.Tables("emp").Rows(i).Item(1))
i = i - 1
Loop
Dim flag As Integer
Dim dr As DataRow
Dim dt As DataTable
Dim pid As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SqlDataAdapter1.Fill(DataSet11)
bm = Me.BindingContext(DataSet11, "Employees")
bm.Position = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
bm.Position = 0
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
bm.Position -= 1
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
bm.Position += 1
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
bm.Position = bm.Count - 1
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
Dim ctr, len As Integer
Dim pid As String
dt = DataSet11.Tables("Employees")
len = (dt.Rows.Count - 1)
dr = dt.Rows(len)
pid = dr("EmployeeID")
ctr = CInt(pid) + 1
TextBox1.Text = ctr
flag = 1
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
pid = TextBox1.Text
flag = 2
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
pid = TextBox1.Text
dt = DataSet11.Tables("Employees")
dr = dt.Rows.Find(pid)
dr.Delete()
SqlDataAdapter1.Update(DataSet11, "Employees")
SqlDataAdapter1.Fill(DataSet11)
bm.Position = 0
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If flag = 1 Then
dt = DataSet11.Tables("Employees")
dr = dt.NewRow
dr(0) = TextBox1.Text
dr(1) = TextBox2.Text
dr(2) = TextBox3.Text
dt.Rows.Add(dr)
ElseIf flag = 2 Then
dt = DataSet11.Tables("Employees")
dr = dt.Rows.Find(pid)
dr.BeginEdit()
dr(1) = TextBox2.Text
dr(2) = TextBox3.Text
dr.EndEdit()
TextBox1.Enabled = True
End If
flag = 0
SqlDataAdapter1.Update(DataSet11, "Employees")
SqlDataAdapter1.Fill(DataSet11)
bm.Position = 0
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SqlDataAdapter1.Fill(DataSet11)
Dim dv As New DataView(DataSet11.Tables("customers"))
Dim s1 As String
s1 = "City=" & "'" & TextBox1.Text & "'"
dv.RowFilter = s1
dv.Sort = "CustomerID Desc"
DataGrid1.DataSource = dv
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataSet11.Clear()
SqlDataAdapter1.SelectCommand.Parameters("@pCity").Value = TextBox1.Text
SqlDataAdapter1.Fill(DataSet11)
End Sub