To get the last code from table in mysql , example we want to show last id from idcustomer to textbox , the code is below
Private void Form1_load(Object sender, EventArgs e){string connection = “Server=servername;user=username;database=dbsales”;string kode;int iNumber,iHasil;MysqlConnection conn = New MysqlConnection();MysqlReader reader ;MysqlCommand comm = New MysqlCommand();conn = New MysqlConnection(connection);conn.Open();comm = con.CreateCommand();comm.CommandText = “Select id from idcustomer;”;reader.ExecuteReader();while (Reader.read()){kode = Reader.GetString(“idcustomer”);iNumber = Convert.ToInt32(kode);iHasil = iNumber + 1;Textbox1.Text = iHasil.ToString;}conn.Close();}