Solved

Sql SELECT will not work with variable

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
Regex validation 2 28
Call an IPL program from vb.net and pass in a file location parmeter 2 27
get row value in vb.net 4 18
RLDC Reporting in Visual studio 11 30
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 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