Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
'it is search button coding
If TextBox1.Text = "" Then
Else
Dim connection As OleDb.OleDbConnection = New OleDbConnection
connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Database16.accdb"
connection.Open()
Dim da1 As OleDb.OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM Table1 WHERE Number_R='" & TextBox1.Text & "';", connection)
Dim ds1 As New DataSet
da1.Fill(ds1)
connection.Dispose()
connection = Nothing
If ds1.Tables(0).Rows.Count > 0 Then
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Database16.accdb"
con.Open()
sql = "SELECT * FROM Table1 WHERE Number_R ='" & TextBox1.Text & "'"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Name_E")
da.Fill(ds, "DOB_B")
da.Fill(ds, "Phone_E")
da.Fill(ds, "Address_S")
con.Close()
TextBox2.Text = ds.Tables("Name_E").Rows(0).Item(2)
TextBox3.Text = ds.Tables("DOB_B").Rows(0).Item(3)
TextBox4.Text = ds.Tables("Phone_E").Rows(0).Item(4)
TextBox5.Text = ds.Tables("Address_S").Rows(0).Item(5)
Dim connection1 As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Database16.accdb")
Dim command As New System.Data.OleDb.OleDbCommand("SELECT Image_E FROM Table1 WHERE Number_R='" & TextBox1.Text & "'", connection1)
connection1.Open()
Dim pictureData As Byte() = DirectCast(command.ExecuteScalar(), Byte())
connection1.Close()
Dim pictures As Image = Nothing
Using Stream As New System.IO.MemoryStream(pictureData)
pictures = Image.FromStream(Stream)
End Using
PictureBox1.Image = pictures
MessageBox.Show("Record Found")
Else
MessageBox.Show("Record NOt Found")
End If
End If
End Sub
Imports System.IO
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Save File In .txt (Notepad)
Dim Save As New SaveFileDialog()
Dim myStreamWriter As System.IO.StreamWriter
Save.Filter = "Text [*.txt*]|*.txt"
Save.CheckPathExists = True
Save.Title = "Save File"
Save.ShowDialog(Me)
Try
myStreamWriter = System.IO.File.AppendText(Save.FileName)
myStreamWriter.Write(TextBox1.Text)
myStreamWriter.Flush()
Catch ex As Exception
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
System.IO.File.WriteAllText(SaveFileDialog1.FileName, TextBox1.Text)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SaveFileDialog1.Filter = "Word Documents|*.doc"
End Sub
End Class
Post a Comment