Solved

Sql SELECT will not work with variable

Posted on 2009-05-12
3
203 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
Comment Utility
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
Comment Utility
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
Comment Utility
That did the trick, thanks.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

15 Experts available now in Live!

Get 1:1 Help Now