开发者

vb6 sql database error

开发者 https://www.devze.com 2023-03-18 17:40 出处:网络
I am attempting to fill textboxes with info pulled by the SQL que开发者_开发技巧ry found in this code:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消