jboy12
jboy12

Reputation: 3916

vb6 sql database error

I am attempting to fill textboxes with info pulled by the SQL query found in this code:

Dim Sqlstring As String
Dim rstCurrentTicket As Recordset

Sqlstring = "SELECT SubmiterName, Department, Description, Urgency, SubmitDate,     ResolvedDate 
               FROM TroubleTickets 
              WHERE Title = " + Trim(TicketComboBox.Text)

SET rstCurrentTicket = cnnSel.OpenRecordset(Sqlstring)

Do While Not rstCurrentTicket.EOF

  TicketComboBox.AddItem (rstCurrentTicket!TroubleTicketTitle)

Loop

the debugger is currently flaging the Set rstCurrentTicket statement. and giving me an an error that says

RUN TIME ERROR 3146 ODBC Call failed

Upvotes: 0

Views: 570

Answers (1)

Jay Riggs
Jay Riggs

Reputation: 53603

Assuming Title is a string, try changing your assignment to Sqlstring to this:

Sqlstring = "Select SubmiterName, Department, Description, Urgency, SubmitDate,     ResolvedDate from TroubleTickets where Title ='" & Trim(TicketComboBox.Text) & "'"

You'll need the single quote qualifiers around your TicketComboBox text to tell the SQL statement you're working with a String.

Upvotes: 1

Related Questions