我有这些代码
Call Connection
Dim SQLInsert As String
SQLInsert = "INSERT INTO `Admin` (" & _
"`kode`," & _
"`nama`," & _
"`password`," & _
"`level`" & _
") VALUES (" & _
"'" & Text1.Text & "', " & _
"'" & Text2.Text & "', " & _
"'" & Text3.Text & "', " & _
"'" & Combo1.Text & "'" & _
")"
conn.Execute SQLInsert
MsgBox "Insert Succeed"
如何从执行上面的语句中获得返回值,无论代码成功还是失败…
我想获得返回值就像PHP中的
<?php
$result = mysqli_query($link, $sql);
if ($result)
//executing other code
如何在VB6中做到这一点?由于
应该有可能得到'行影响'值回来。请阅读此Microsoft链接:
https://msdn.microsoft.com/en-us/library/ms681559 (v = vs.85) . aspx
你需要添加'adExecuteNoRecords'选项,章节' comments '
阅读有关ON ERROR语句的信息。它允许在VB中处理异常。
Dim SQLInsert As String
ON ERROR GOTO ErrorHandler
SQLInsert = "INSERT INTO `Admin` (" & _
"`kode`," & _
"`nama`," & _
"`password`," & _
"`level`" & _
") VALUES (" & _
"'" & Text1.Text & "', " & _
"'" & Text2.Text & "', " & _
"'" & Text3.Text & "', " & _
"'" & Combo1.Text & "'" & _
")"
conn.Execute SQLInsert
MsgBox "Insert Succeed"
Exit Sub
ErrorHandler:
Msg = "Error # " & Str(Err.Number) & " was generated by " &
Err.Source & ControlChars.CrLf & Err.Description
MsgBox(Msg, MsgBoxStyle.Information, "Error")
Exit Sub