Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Public Class ViewNotes
Dim sqlConn As New SqlConnection
Private mySQLConnection As New SqlConnection
Private mySQLDataAdapter As SqlDataAdapter
Private mySQLCommandBuilder As SqlCommandBuilder
Private myDataTable As New DataTable
Private RowPosition As Integer
Private Sub ViewBookCode_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
mySQLConnection.Close()
mySQLConnection.Dispose()
End Sub
Private Sub ViewBookCode_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mySQLConnection.ConnectionString = "Data Source=VISTA-ON-MAC\SQLEXPRESS;Initial Catalog=WriterDemo;Persist Security Info=True;User ID=sa;Password=peter;Connect Timeout=30"
Dim customer_id As Integer
customer_id = 1
mySQLConnection.Open()
mySQLDataAdapter = New SqlDataAdapter("SELECT * FROM t_notes WHERE customer_id =" & customer_id, sqlConn)
mySQLDataAdapter = New SqlDataAdapter
mySQLCommandBuilder = New SqlCommandBuilder(mySQLDataAdapter)
mySQLDataAdapter.Fill(myDataTable)
Me.ShowCurrentRecord()
End Sub
Private Sub ShowCurrentRecord()
If myDataTable.Rows.Count = 0 Then
txtNotes.Text = ""
Exit Sub
End If
txtNotes.Text = myDataTable.Rows(RowPosition)("note").ToString()
End Sub
End Class
|