开发者

VB6 and SQL mistake

Here is a line of code in SQL I am attempting to use in VB6.

Dim Sqlstring As String

Sqlstring = "Update TroubleTickets set ResolvedDate = ' " + DateValue(Now) + "' where      Title ='" + Trim(TicketComboBox.Text) + "'"

I am getting an error tha开发者_高级运维t says types do not match when i run the debugger.

any suggestions?


Dim Sqlstring As String

Sqlstring = "Update TroubleTickets set ResolvedDate = ' " & DateValue(Now) & "' where      Title ='" & Trim(TicketComboBox.Text) & "'"

The concat-operator in VB is the ampersand &. You get a type mismatch error because VB expects a number if you use +.

You should also consider using prepared statements to insert parameters into SQL queries.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜