Hello guys. Thought I would give you an Update as I have finally worked it out.
Code:Imports System.Data.OleDb Public Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim KKK As Integer = CInt(Form1.txtPrimkey.Text) Dim EMP As OleDb.OleDbConnection Dim ConnectToMyDatabase As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= N:\VB.NET\ReadingFromDatabase\ReadingFromDatabase\Resources\Data.accdb;Persist Security Info=False;" EMP = New OleDb.OleDbConnection(ConnectToMyDatabase) EMP.Open() Dim cmd As OleDbCommand cmd = New OleDbCommand("select * from MP where ID = " & KKK, EMP) Dim dr As OleDbDataReader = cmd.ExecuteReader() While dr.Read() txtID.Text = dr(0) txtName.Text = dr(1) txtGender.Text = dr(2) txtAge.Text = dr(3) TxtMoney.Text = dr(4) End While End Sub End Class 'cmd = New OleDbCommand("select * from MP where Name = '" & txtName.Text & "'", EMP) This is for a string.




Reply With Quote