Solved

Sql SELECT will not work with variable

Posted on 2009-05-12
3
207 Views
Last Modified: 2012-05-06
I would appreciate any assistance with getting my sql select statement to work so that any matches from data in my textbox will result in my dgv being populated with the matches.  Right now I just get a blank dg, even though I know there are matches.
Dim cString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/log1/labeldb.mdb"
        Dim sqlString As String = "SELECT * FROM Log1 WHERE wDD=" & tDate.Text
        Dim OleDBCon As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(cString)
        Dim DataSet As New DataSet()
        Dim OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(sqlString, OleDBCon)
        OleDBCon.Open()
        OleDbDataAdapter1.Fill(DataSet, "Log1")
        DG1.DataSource = DataSet.Tables("Log1")

Open in new window

0
Comment
Question by:Fingerlakesconst
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
johnnash1180 earned 500 total points
ID: 24366115
Check the date format(?) entered in the tDate text box. Also try the following format...

Dim sqlString As String = "SELECT * FROM Log1 WHERE wDD='" & tDate.Text & "'"

John Nash
0
 

Author Comment

by:Fingerlakesconst
ID: 24366165
Thanks, yours seems to have more spacing between the single and double quotes than all of the combinations I've been trying for the past hour or so.  I'll let you know in a few minutes after I run it.
0
 

Author Comment

by:Fingerlakesconst
ID: 24366206
That did the trick, thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question