Hi fellow developers. I have having a little problem accessing a ms access Database using VB.NET. I have got most of the bulk of the code working and I have got it working before but this time it has stumpped me.
The line that the error apears on is this one.Code:Imports System.Data.OleDb Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Form2.Show() 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 Dim dr As OleDbDataReader cmd = New OleDbCommand("select * from Data where ID = txtPrimKey.Text", EMP) dr = cmd.ExecuteReader While dr.Read() Form2.txtID.Text = dr(0) Form2.txtName.Text = dr(1) Form2.txtGender.Text = dr(2) Form2.txtAge.Text = dr(3) Form2.TxtMoney.Text = dr(4) End While End Sub End Class
It says that there is no value given.Code:dr = cmd.ExecuteReader
Thanks in advance.
JockGitJnr




Reply With Quote