Getting data into a vb.net form from Access database
Posted on 2010-08-17
Would this code work? I am trying to count the number of "A" entered in the Response field.
the database is called Survey.
Dim number As Integer
Dim con As OleDbConnection
Dim comm As OleDbCommand
Dim reader As OleDbDataReader
con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Survey.accdb;")
comm = New OleDbCommand("Select count(Response)as number from Answers where SurveyID = 1 and QuestionID =1 and Response = 'A'", con)
' Open Connection
' reader read comm
reader = comm.ExecuteReader
' Get from the reader the UserName and UserPasswrod
number = reader.Item("Response")