开发者

VB6 and SQL mistake

开发者 https://www.devze.com 2023-03-19 15:16 出处:网络
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) + \"\' whereTitle =\'\" + Trim(Tick

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

精彩评论

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