我对我的查询表有疑问......我使用VB2005和MS Access作为其数据库。这是我的代码:
Private Sub frmViewInquiries_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim varFromDate As Date = Me.dtpFromDate.Value.ToShortString
Dim varToDate As Date = Me.dtpToDate.Value.ToString
Dim MyDS As New DataSet
Dim MyDA As OdbcDataAdapter = New OdbcDataAdapter("SELECT * FROM tblStudentInfoInq WHERE DateInquired >= "& varFromDate &" AND DateInquired <= "& varToDate &"", MyConn)
MyDa.Fill(MyDS, "tblStudentInfoInq")
Me.dgvInquiryList.DataSource = MyDS.Tables("tblStudentInfoInq")
End Sub
我想获取在FROM和TO DateTimePicker日期值中查询的查询列表。当我使用该代码调试程序时,我无法从数据库中获取记录,因为我有3月7日和8日的记录,这应该出现在我的DataGridView上。我的SQL语法是否正确?提前谢谢。