Scratching my head over this one. I've never attempted to use VB.NET with a database before but I need to now.
I have a database called "Asset Management" and I am currently able to create new records in it but I need to search for records now and I just cant figure out how to do the following.
After creating or changing an asset the analyst will swipe their card which has a specific code embedded. I need to search the table "Badge_Numbers" for this code. If found it will create or update the records in another table.
It also needs to return the analyst name as found in the "Badge_Numbers" table.
So far example the Badge_Numbers table will look like this:
C%7644764 Joe Bloggs
G%5454564 Cindy Crawford
N£2132143 Joan Collins
If Joan swipes her card it needs to look for "N£2132143" and store the name associated with it "Joan Collins" in a string so it can be entered into another table later
Here's the awful code that I have so far:
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim sql As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
dbProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"
dbSource = "Data Source = " & "\\server\Asset Management.accdb"
con.ConnectionString = dbProvider & dbSource
sql = "SELECT * FROM Badge_Numbers"
da = New OleDbDataAdapter(sql, con)
Dim badge As String = txtAnalyst.Text
Dim foundrow As DataRow = ds.Tables("Badge_Numbers").Rows.Find(badge)
If foundrow IsNot Nothing Then
When I run this I receive the error 'Object reference not set to an instance of an object' on this line:
Dim foundrow As DataRow = ds_a.Tables("Badge_Numbers
Any help appreciated