本文介绍了vb6 sql数据库错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试用此代码中找到的SQL查询提取的信息填充文本框:
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
调试器当前正在标记Set rstCurrentTicket语句.并给我一个错误
the debugger is currently flaging the Set rstCurrentTicket statement. and giving me an an error that says
推荐答案
假设Title是一个字符串,请尝试将对Sqlstring
的赋值更改为此:
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) & "'"
您将在TicketComboBox文本周围需要单引号限定符,以告诉您正在使用String的SQL语句.
You'll need the single quote qualifiers around your TicketComboBox text to tell the SQL statement you're working with a String.
这篇关于vb6 sql数据库错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!