Visual Basic/SQL problem

Status
You're currently viewing only maddmurph's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

maddmurph

Ars Tribunus Militum
1,986
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.
 

maddmurph

Ars Tribunus Militum
1,986
after reading another post here I feel I should meantion this is homework, though I am not looking for people to do the work for me I just need to know what is wrong, so any instruction you could give me would be nice. Hopefully, no one has a real big problem with that as I have done the coding but it is buggy, if you feel otherwise please feel free to ask the mods to lock the thread

spammydavis jr.- I don't get your post, could you explain that one to me
 
Status
You're currently viewing only maddmurph's posts. Click here to go back to viewing the entire thread.
Not open for further replies.