I found the answer that said you could return the id with a double query but mine comes up null. Any ideas? The method did work before I switched the bottom line to return an integer instead of just executing the query.
Public Function insertDynamicQuery(ByVal strTable As String, ByVal strParameters As String(), ByVal strParameterValues As String()) As Integer
Dim intParameterCount As Integer = strParameters.Count() - 1
Dim strQuery As String = "INSERT INTO " + strTable + " ("
For i = 0 To intParameterCount
strQuery += strParameters(i)
If i < intParameterCount Then
strQuery += ", "
End If
Next
strQuery += ") VALUES ("
For i = 0 To intParameterCount
strQuery += "@insertparameter" + i.ToString()
If i < intParameterCount Then
strQuery += ", "
End If
Next
strQuery += ");"
strQuery += " SELECT LAST_INSERT_ID() FROM " + strTable + ";"
Dim cmd As New MySqlCommand(strQuery, _DBConnection)
For k = 0 To intParameterCount
cmd.Parameters.AddWithValue("@insertparameter" + k.ToString, strParameterValues(k))
' Console.WriteLine("@insertparameter" + k.ToString + "//" + strParameterValues(k))
Next
Return CInt(cmd.ExecuteScalar())
End Function