Ok I am trying to write a program that will scan a cd and database all the files on the cd, I have that part working but when I try and write the sql code to get it to search the database, I am getting an error.
Here is the code
Private Sub cmdsubmit_Click()
Dim SqlStmt As String
Dim resultcount As Integer
Dim resultlistcount As Integer
Dim resultstring As String
If OptfindCD = True Then
SqlStmt = "SELECT [CD Name], [Path], [File Name] from [CD Explorer] where [CD Name] = " + txtsearch.Text
ElseIf optfindfile = True Then
SqlStmt = "SELECT [CD Name], [Path], [File Name] from [CD Explorer] where [File Name] = " + txtsearch.Text
End If
dbcdexplorerquery.RecordSource = SqlStmt
dbcdexplorerquery.Refresh
dbcdexplorerquery.Recordset.MoveFirst
resultlistcount = dbcdexplorerquery.Recordset.Fields(0)
resultcount = 0
ReDim ids(0 To resultlistcount - 1)
For resultcount = 0 To resultlistcount - 1
resultstring = dbcdexplorerquery.Recordset.Fields("[CD Name]") + dbcdexplorerquery.Recordset.Fields("Path") + dbcdexplorerquery.Recordset.Fields("[File Name]")
lstsearchresults.AddItem (resultstring)
ids(resultcount) = dbcdexplorerquery.Recordset.Fields("[CD Name]")
dbcdexplorerquery.Recordset.MoveNext
Next resultcount
End Sub
The error says "Run Time Error '3061':
Too Few Parameters. Expected 1.
When I hit debug it highlights the line of code that is bolded.
Here is the code
Private Sub cmdsubmit_Click()
Dim SqlStmt As String
Dim resultcount As Integer
Dim resultlistcount As Integer
Dim resultstring As String
If OptfindCD = True Then
SqlStmt = "SELECT [CD Name], [Path], [File Name] from [CD Explorer] where [CD Name] = " + txtsearch.Text
ElseIf optfindfile = True Then
SqlStmt = "SELECT [CD Name], [Path], [File Name] from [CD Explorer] where [File Name] = " + txtsearch.Text
End If
dbcdexplorerquery.RecordSource = SqlStmt
dbcdexplorerquery.Refresh
dbcdexplorerquery.Recordset.MoveFirst
resultlistcount = dbcdexplorerquery.Recordset.Fields(0)
resultcount = 0
ReDim ids(0 To resultlistcount - 1)
For resultcount = 0 To resultlistcount - 1
resultstring = dbcdexplorerquery.Recordset.Fields("[CD Name]") + dbcdexplorerquery.Recordset.Fields("Path") + dbcdexplorerquery.Recordset.Fields("[File Name]")
lstsearchresults.AddItem (resultstring)
ids(resultcount) = dbcdexplorerquery.Recordset.Fields("[CD Name]")
dbcdexplorerquery.Recordset.MoveNext
Next resultcount
End Sub
The error says "Run Time Error '3061':
Too Few Parameters. Expected 1.
When I hit debug it highlights the line of code that is bolded.