0% found this document useful (0 votes)
29 views2 pages

Imports System

This code connects to a SQL database, retrieves employee data into a dataset, and displays the employee ID in a text box. It includes buttons to navigate between records, displaying the ID from the current row in the text box. When the first or last record is reached, a message is shown instead of changing the row.

Uploaded by

Janaka Vidurinda
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

Imports System

This code connects to a SQL database, retrieves employee data into a dataset, and displays the employee ID in a text box. It includes buttons to navigate between records, displaying the ID from the current row in the text box. When the first or last record is reached, a message is shown instead of changing the row.

Uploaded by

Janaka Vidurinda
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Imports System.Data.

SqlClient Public Class Form1 Dim i As Integer Dim ds As New DataSet() Dim sql As String Dim con As SqlConnection Dim da As SqlDataAdapter Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

con = New SqlConnection("Data Source=USER-PC;Initial Catalog=employee;User ID=sa;Password=corolla") con.Open() sql = "SELECT * from emp" da = New SqlDataAdapter(sql, con) da.Fill(ds, "emp") ' TextBox1.DataBindings.Add("text", dt, "emp.empid") 'TextBox1.Text = "Hello" TextBox1.Text = ds.Tables("emp").Rows(i).Item(0) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If i < ds.Tables("emp").Rows.Count - 1 Then i = i + 1 TextBox1.Text = ds.Tables("emp").Rows(i).Item(0) Else MessageBox.Show("SSSSSSSSSSSS") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If i = ds.Tables("emp").Rows.Count - 1 Or i <> 0 Then i = i - 1 TextBox1.Text = ds.Tables("emp").Rows(i).Item(0) Else MessageBox.Show("AAAAAAAAAAAAA") End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If i <> 0 Then i = 0 TextBox1.Text = ds.Tables("emp").Rows(i).Item(0) End If End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If i <> ds.Tables("emp").Rows.Count - 1 Then i = ds.Tables("emp").Rows.Count - 1 TextBox1.Text = ds.Tables("emp").Rows(i).Item(0) End If End Sub End Class

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy