Hi,
I have a MS Access DB with a query that I need to display in vb but am not too sure on how to go about it. The query has some criteria - i.e you have to input a date to run the query. I think that's a parameter in vb......
Well I've been playing around with it for some time now but amn't really getting anywhere. Could ye recommend any good tutorial or link as to how to do it?
Here's the code that I've been working on:
I've been trying to reference the query as a dataset. But should I write the SQL code someplace??
Also, when I run it I get the error: "No value given for one or more required parameters"
Help would be greatly appreciated.
I have a MS Access DB with a query that I need to display in vb but am not too sure on how to go about it. The query has some criteria - i.e you have to input a date to run the query. I think that's a parameter in vb......
Well I've been playing around with it for some time now but amn't really getting anywhere. Could ye recommend any good tutorial or link as to how to do it?
Here's the code that I've been working on:
Code:
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Public Class frmTodaysAbsentees
Inherits System.Windows.Forms.Form
Dim objDataSet As New DataSet
Dim dateToday = Now.Date
Dim objConnection As New OleDb.OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= FYP.mdb")
Dim objAbsenteesDA As New OleDb.OleDbDataAdapter("Select * from TodaysAbsentees", objConnection)
Dim objAbsenteesCB As New OleDb.OleDbCommandBuilder(objAbsenteesDA)
Dim objRow As DataRow
Private Sub frmTodaysAbsentees_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DataSet2.TodaysAbsentees' table. You can move, or remove it, as needed.
'Me.TodaysAbsenteesTableAdapter.Fill(Me.DataSet2.TodaysAbsentees)
'clear data set of any existing data
objDataSet.Clear()
'fill the data set with infro from the 'TodaysAbsentees' query
objAbsenteesDA.FillSchema(objDataSet, SchemaType.Source, "TodaysAbsentees")
objAbsenteesDA.Fill(objDataSet, "TodaysAbsentees")
'setup the relationship
objDataSet.Relations.Clear()
objDataSet.Relations.Add("Class2Student", _
objDataSet.Tables("tblClass").Columns("ClassID"), _
objDataSet.Tables("tblStudent").Columns("ClassID"))
objDataSet.Relations.Add("Student2Attendance", _
objDataSet.Tables("tblStudent").Columns("StudentID"), _
objDataSet.Tables("tblAttendance").Columns("StudentID"))
lstAbsentStudents.Items.Clear()
Dim I As Integer
Dim strCurrent As String
Dim strCurrent1 As String
For I = 1 To objDataSet.Tables("TodaysAbsentees").Rows.Count
strCurrent = objDataSet.Tables("TodaysAbsentees").Rows(I - 1).Item("SName")
strCurrent1 = objDataSet.Tables("TodaysAbsentees").Rows(I - 1).Item("FName")
lstAbsentStudents.Items.Add(strCurrent + ", " + strCurrent1)
Next
End Sub
Also, when I run it I get the error: "No value given for one or more required parameters"
Help would be greatly appreciated.
Comment