vb6 sql database error

痴心易碎 提交于 2019-12-12 00:00:00

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/6587754/vb6-sql-database-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!