When I try to show the data in my database in tableView
I get that error and if I convert it in NSTableViewDataSource I get a System.ExceptionCatch
. It's the first time this error has happened to me. If someone knows how to fix it or thinks it can be please tell me about it.
Sorry for not uploading it in text format and thanks for the suggestions. Here it is:
public partial class ViewController : NSViewController
{
dataBase sql = new dataBase();
public ViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
tableView.DataSource = sql.MostrarDatos();
// Do any additional setup after loading the view.
}
public override NSObject RepresentedObject
{
get
{
return base.RepresentedObject;
}
set
{
base.RepresentedObject = value;
// Update the view, if already loaded.
}
}
}
And this is the error:
Error CS0266: Can not implicitly convert type 'System.Data.DataTable' to 'AppKit.INSTableViewDataSource'. An explicit conversion exists (are you missing a cast?) (CS0266)
And here the ShowData code:
public class dataBase
{
private MySqlConnection cnx = new MySqlConnection("server = 127.0.0.1; database=Facturas; Uid=root;pwd=pablo_37;");
private DataSet ds;
public void ProbarConexion()
{
var alert = new NSAlert();
try
{
cnx.Open();
alert.InformativeText = "Conectado";
alert.RunModal();
}
catch (Exception r)
{
alert.MessageText = r.Message;
alert.RunModal();
}
finally { cnx.Close(); }
}
public DataTable MostrarDatos()
{
cnx.Open();
MySqlCommand cmd = new MySqlCommand("select * from Factura", cnx);
MySqlDataAdapter ad = new MySqlDataAdapter(cmd);
ds = new DataSet();
ad.Fill(ds, "Factura");
return ds.Tables["Factura"];
}
}
For the application I am using visual studio with Xcode and mysql in case someone has already worked with it and knows something about the problem or another solution to be able to query the tables through them. The application is desktop. Thanks for your help and comments in advance.