MYSQL How do get all of my SELECT information?

I have a very simple select command as noted below.

dbCommand.CommandText = "SELECT * FROM ticket WHERE Product = '" + searchModel +"'";

This constantly errors out with

InvalidCastException: Cannot cast from source type to destination type.

However, when I change the select to this

dbCommand.CommandText = "SELECT * FROM ticket WHERE ID = '166777'";

The command is able to find all of my values from that column without a problem.

I have been stuck on this for a couple of days with no end in sight. This is a project for my work, and I need to understand what I am doing wrong.

Any help is GREATLY appreciated.

Thank you.

1 - I downloaded the Connector / Net (Net & Mono version 2.0.).

2 - Insert the mysql.data.dll the project.

3 - I configured. NET in my project = Edit / Project Settings / Player / Optimization / Api Compatibility Level>. NET 2.0.

4 - I created this script below:

using UnityEngine;
using System.Collections;
using MySql.Data.MySqlClient;

public class ConexaoBanco : MonoBehaviour {
private string source;
private MySqlConnection conexao;

void Start () {

source =     "Server=localhost;" +
             "Database = yourDataBaseSQL;" +  
             "User ID = root;" +
             "Pooling = false;" +
             "Password= yourpassword";


       ConexaoBanco(source);
       Listar (conexao);

   }

   // Update is called once per frame
   void Update () {

   }

   void ConectarBanco (string _source){
   conexao = new MySqlConnection (_source);
   conexao.Open ();
   }

void Listar (MySqlConnection _conexao){
MySqlCommand comando = _conexao.CreateCommand();
comando.CommandText = "Select * from voz_principal";
MySqlDataReader dados = comando.ExecuteReader();

while (dados.Read()){
   string nome = (string)dados["nome"];


          Debug.Log("Usuario " + nome);

        }

     }

   }

///////////////////////////////////

(Reference: Unity e MySql - YouTube)

This was answered by me. It appears that all I need to do is ask the question and the answer will come to me :slight_smile:

However, any insight is always appreciated.