I am attempting to fill textboxes with info pulled by the SQL que开发者_开发技巧ry 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
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.
精彩评论