Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sql SELECT will not work with variable

Posted on 2009-05-12
3
Medium Priority
?
211 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 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

636 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