Solved

Sql SELECT will not work with variable

Posted on 2009-05-12
3
204 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

895 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now