O
orandov
I am new to Access DB. I am trying to get data from Access DB in VB.NET
and I get this error: no value given for one or more required
parameters.
Here is my code:
sSql = "SELECT h.RO_DATE, Sum(h.CHARGE) AS SumOfCHARGE,
h.TECH_NO, t.TECH_NAME, Employee.EMPLOYEE_NO " _
& "FROM (HLabor AS h LEFT JOIN Tech AS t ON h.TECH_NO = t.TECH)
LEFT JOIN Employee AS e ON t.TECH_NAME = e.BNAME " _
& "WHERE h.RO_DATE >= #" & dtStartDate.ToShortDateString & "# " _
& "AND h.RO_DATE <= #" & dtEndDate.ToShortDateString & "# " _
& "GROUP BY h.RO_DATE, h.TECH_NO, t.TECH_NAME,
e.EMPLOYEE_NO " _
& "ORDER BY t.TECH_NAME DESC"
iRecCount = modMain.Access.GetDataTable(oDT, sSql)
Public Function GetDataTable(ByRef oDT As DataTable, ByVal sSQL As
String) As Integer
Dim iRetVal As Integer
Dim oOleDbConnection As OleDb.OleDbConnection = GetConnection()
Dim oOleDbCommand As OleDb.OleDbCommand
Dim oOleDbDataAdapter As OleDb.OleDbDataAdapter
oOleDbCommand = New OleDb.OleDbCommand
oOleDbCommand.Connection = oOleDbConnection
oOleDbCommand.CommandType = CommandType.Text
oOleDbCommand.CommandText = sSQL
oOleDbDataAdapter = New OleDb.OleDbDataAdapter(oOleDbCommand)
Try
oOleDbConnection.Open()
Catch err As OleDb.OleDbException
MessageBox.Show(err.Message)
End Try
Try
iRetVal = oOleDbDataAdapter.Fill(oDT)
Catch err1 As OleDb.OleDbException
MessageBox.Show(err1.Message)
End Try
oOleDbConnection.Close()
Return iRetVal
End Function
Any Suggestions?
Thank you,
Oran
and I get this error: no value given for one or more required
parameters.
Here is my code:
sSql = "SELECT h.RO_DATE, Sum(h.CHARGE) AS SumOfCHARGE,
h.TECH_NO, t.TECH_NAME, Employee.EMPLOYEE_NO " _
& "FROM (HLabor AS h LEFT JOIN Tech AS t ON h.TECH_NO = t.TECH)
LEFT JOIN Employee AS e ON t.TECH_NAME = e.BNAME " _
& "WHERE h.RO_DATE >= #" & dtStartDate.ToShortDateString & "# " _
& "AND h.RO_DATE <= #" & dtEndDate.ToShortDateString & "# " _
& "GROUP BY h.RO_DATE, h.TECH_NO, t.TECH_NAME,
e.EMPLOYEE_NO " _
& "ORDER BY t.TECH_NAME DESC"
iRecCount = modMain.Access.GetDataTable(oDT, sSql)
Public Function GetDataTable(ByRef oDT As DataTable, ByVal sSQL As
String) As Integer
Dim iRetVal As Integer
Dim oOleDbConnection As OleDb.OleDbConnection = GetConnection()
Dim oOleDbCommand As OleDb.OleDbCommand
Dim oOleDbDataAdapter As OleDb.OleDbDataAdapter
oOleDbCommand = New OleDb.OleDbCommand
oOleDbCommand.Connection = oOleDbConnection
oOleDbCommand.CommandType = CommandType.Text
oOleDbCommand.CommandText = sSQL
oOleDbDataAdapter = New OleDb.OleDbDataAdapter(oOleDbCommand)
Try
oOleDbConnection.Open()
Catch err As OleDb.OleDbException
MessageBox.Show(err.Message)
End Try
Try
iRetVal = oOleDbDataAdapter.Fill(oDT)
Catch err1 As OleDb.OleDbException
MessageBox.Show(err1.Message)
End Try
oOleDbConnection.Close()
Return iRetVal
End Function
Any Suggestions?
Thank you,
Oran